| 477 | } |
| 478 | |
| 479 | SAM_EXPORT int SAM_module_exec(const char* cmod, void* data, int verbosity, SAM_error *err){ |
| 480 | translateExceptions(err, [&]{ |
| 481 | ssc_module_t cm = ssc_module_create(cmod); |
| 482 | if (!cm) throw std::runtime_error("Unable to create compute_module " + std::string(cmod)); |
| 483 | |
| 484 | if(verbosity == 0){ |
| 485 | ssc_module_exec_set_print(0); |
| 486 | } |
| 487 | |
| 488 | if (!ssc_module_exec( cm, data )){ |
| 489 | std::string str = std::string(cmod) + " execution error.\n"; |
| 490 | int idx = 0; |
| 491 | while ( const char *msg = ssc_module_log( cm, idx++, nullptr, nullptr ) ) |
| 492 | { |
| 493 | str += "\t"; |
| 494 | str += std::string(msg); |
| 495 | str += "\n\n"; |
| 496 | } |
| 497 | ssc_module_free(cm); |
| 498 | throw std::runtime_error(str); |
| 499 | } |
| 500 | ssc_module_free(cm); |
| 501 | }); |
| 502 | return 1; |
| 503 | } |
| 504 | |
| 505 | SAM_EXPORT int SAM_stateful_module_exec(SAM_module cm, SAM_table data, int verbosity, SAM_error *err) { |
| 506 | translateExceptions(err, [&]{ |