diff --git a/flow/Error.cpp b/flow/Error.cpp index 3edb81adf9..4f80d6e980 100644 --- a/flow/Error.cpp +++ b/flow/Error.cpp @@ -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();