[R-pkg-devel] how to throw a C++ exception across modules

Joshua N Pritikin jpr|t|k|n @end|ng |rom pobox@com
Sat Sep 28 01:56:20 CEST 2019


OpenMx exports an API that I import into another package (gwsem) like 
this,

  aldp = R_GetCCallable("OpenMx", "AddLoadDataProvider")

gwsem registers some C++ classes through this API.

This works great until gwsem throws a C++ exception. OpenMx calls gwsem in 
a try-catch region. This works flawlessly on Linux. However, it seems to 
not work on Windows. win-builder.r-project.org complained,

** running tests for arch 'i386' ... [23s] ERROR
  Running 'testthat.R' [22s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(gwsem)
  Loading required package: OpenMx
  > 
  > test_check("gwsem")
  
  This application has requested the Runtime to terminate it in an unusual way.
  Please contact the application's support team for more information.
  terminate called after throwing an instance of 'std::runtime_error'
    what():  MxComputeLoadData: out of data (record 250 requested but only 199 in file)

What solution is recommended?

Thank you.

-- 
Joshua N. Pritikin, Ph.D.
Virginia Institute for Psychiatric and Behavioral Genetics
Virginia Commonwealth University
PO Box 980126
800 E Leigh St, Biotech One, Suite 1-133
Richmond, VA 23219
http://exuberant-island.surge.sh



More information about the R-package-devel mailing list