Skip to content

Commit

Permalink
call_sirius -> dump core if SIRIUS_COREDUMP=1 env is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpintarelli committed Jun 13, 2024
1 parent 33161ba commit 550f0f7
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions src/api/sirius_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,37 +239,47 @@ template <typename F>
static void
call_sirius(F&& f__, int* error_code__)
{
// try {
f__();
if (error_code__) {
*error_code__ = SIRIUS_SUCCESS;
auto val = env::get_value_ptr<int>("SIRIUS_COREDUMP");
bool coredump = false;
if(val != nullptr) {
coredump = *val == 1;
}
if (coredump) {
f__();
return;
}
// } catch (std::runtime_error const& e) {
// if (error_code__) {
// *error_code__ = SIRIUS_ERROR_RUNTIME;
// sirius_print_error(*error_code__, e.what());
// return;
// } else {
// sirius_exit(SIRIUS_ERROR_RUNTIME, e.what());
// }
// } catch (std::exception const& e) {
// if (error_code__) {
// *error_code__ = SIRIUS_ERROR_EXCEPTION;
// sirius_print_error(*error_code__, e.what());
// return;
// } else {
// sirius_exit(SIRIUS_ERROR_EXCEPTION, e.what());
// }
// } catch (...) {
// if (error_code__) {
// *error_code__ = SIRIUS_ERROR_UNKNOWN;
// sirius_print_error(*error_code__);
// return;
// } else {
// sirius_exit(SIRIUS_ERROR_UNKNOWN);
// }
// }

try {
f__();
if (error_code__) {
*error_code__ = SIRIUS_SUCCESS;
return;
}
} catch (std::runtime_error const& e) {
if (error_code__) {
*error_code__ = SIRIUS_ERROR_RUNTIME;
sirius_print_error(*error_code__, e.what());
return;
} else {
sirius_exit(SIRIUS_ERROR_RUNTIME, e.what());
}
} catch (std::exception const& e) {
if (error_code__) {
*error_code__ = SIRIUS_ERROR_EXCEPTION;
sirius_print_error(*error_code__, e.what());
return;
} else {
sirius_exit(SIRIUS_ERROR_EXCEPTION, e.what());
}
} catch (...) {
if (error_code__) {
*error_code__ = SIRIUS_ERROR_UNKNOWN;
sirius_print_error(*error_code__);
return;
} else {
sirius_exit(SIRIUS_ERROR_UNKNOWN);
}
}
}

template <typename T>
Expand Down

0 comments on commit 550f0f7

Please sign in to comment.