| 23 | } |
| 24 | |
| 25 | TString CurrentExceptionMessage() { |
| 26 | auto exceptionPtr = std::current_exception(); |
| 27 | if (exceptionPtr) { |
| 28 | try { |
| 29 | std::rethrow_exception(exceptionPtr); |
| 30 | } catch (const yexception& e) { |
| 31 | const TBackTrace* bt = e.BackTrace(); |
| 32 | |
| 33 | if (bt) { |
| 34 | return TString::Join(bt->PrintToString(), TStringBuf("\n"), FormatExc(e)); |
| 35 | } |
| 36 | |
| 37 | return FormatExc(e); |
| 38 | } catch (const std::exception& e) { |
| 39 | return FormatExc(e); |
| 40 | } catch (...) { |
| 41 | } |
| 42 | |
| 43 | return "unknown error"; |
| 44 | } |
| 45 | |
| 46 | return "(NO EXCEPTION)"; |
| 47 | } |
| 48 | |
| 49 | Y_DECLARE_UNUSED static void FormatBackTraceTo(IOutputStream& out, const TBackTrace& backtrace) { |
| 50 | if (backtrace.size() == 0) { |