| 104 | } |
| 105 | |
| 106 | Error::Error(int error_code) : error_code(error_code), flags(0) { |
| 107 | if (TRACE_SAMPLE()) |
| 108 | TraceEvent(SevSample, "ErrorCreated").detail("ErrorCode", error_code); |
| 109 | // std::cout << "Error: " << error_code << std::endl; |
| 110 | if (error_code >= 3000 && error_code < 6000) { |
| 111 | { |
| 112 | TraceEvent te(SevError, "SystemError"); |
| 113 | te.error(*this).backtrace(); |
| 114 | if (error_code == error_code_unknown_error) { |
| 115 | auto exception = std::current_exception(); |
| 116 | if (exception) { |
| 117 | try { |
| 118 | std::rethrow_exception(exception); |
| 119 | } catch (std::exception& e) { |
| 120 | te.detail("StdException", e.what()); |
| 121 | } catch (...) { |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | if (g_crashOnError) { |
| 127 | flushOutputStreams(); |
| 128 | flushTraceFileVoid(); |
| 129 | crashAndDie(); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | #if DEBUG_ERROR |
| 134 | if (SHOULD_LOG_ERROR(error_code)) { |
| 135 | TraceEvent te(SevWarn, "DebugError"); |
| 136 | te.error(*this).backtrace(); |
| 137 | if (error_code == error_code_unknown_error) { |
| 138 | auto exception = std::current_exception(); |
| 139 | if (exception) { |
| 140 | try { |
| 141 | std::rethrow_exception(exception); |
| 142 | } catch (std::exception& e) { |
| 143 | te.detail("StdException", e.what()); |
| 144 | } catch (...) { |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | #endif |
| 150 | } |
| 151 | |
| 152 | ErrorCodeTable& Error::errorCodeTable() { |
| 153 | static ErrorCodeTable table; |