| 60 | } |
| 61 | |
| 62 | void FormatCurrentExceptionTo(IOutputStream& out) { |
| 63 | auto exceptionPtr = std::current_exception(); |
| 64 | |
| 65 | if (Y_UNLIKELY(!exceptionPtr)) { |
| 66 | out << "(NO EXCEPTION)\n"; |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | #ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE |
| 71 | TBackTrace backtrace = TBackTrace::FromCurrentException(); |
| 72 | #endif |
| 73 | try { |
| 74 | std::rethrow_exception(exceptionPtr); |
| 75 | } catch (const std::exception& e) { |
| 76 | out << "Caught:\n"; |
| 77 | FormatExceptionTo(out, e); |
| 78 | out << "\n"; |
| 79 | #ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE |
| 80 | FormatBackTraceTo(out, backtrace); |
| 81 | #endif |
| 82 | return; |
| 83 | } catch (...) { |
| 84 | out << "unknown error\n"; |
| 85 | return; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | TString FormatCurrentException() { |
| 90 | TStringStream out; |
no test coverage detected