Merge pull request #4331 from sfc-gh-anoyes/anoyes/std-exception

Log std::exception::what when creating an unknown_error
This commit is contained in:
Markus Pilman 2021-02-13 12:34:24 -07:00 committed by GitHub
commit 6b1b127ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 5 deletions

View File

@ -57,13 +57,25 @@ Error internal_error_impl( const char* file, int line ) {
return Error(error_code_internal_error);
}
Error::Error(int error_code)
: error_code(error_code), flags(0)
{
Error::Error(int error_code) : error_code(error_code), flags(0) {
if (TRACE_SAMPLE()) TraceEvent(SevSample, "ErrorCreated").detail("ErrorCode", error_code);
//std::cout << "Error: " << error_code << std::endl;
// std::cout << "Error: " << error_code << std::endl;
if (error_code >= 3000 && error_code < 6000) {
TraceEvent(SevError, "SystemError").error(*this).backtrace();
{
TraceEvent te(SevError, "SystemError");
te.error(*this).backtrace();
if (error_code == error_code_unknown_error) {
auto exception = std::current_exception();
if (exception) {
try {
std::rethrow_exception(exception);
} catch (std::exception& e) {
te.detail("StdException", e.what());
} catch (...) {
}
}
}
}
if (g_crashOnError) {
flushOutputStreams();
flushTraceFileVoid();