MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getCurrentExceptionMessageAndPattern

Function getCurrentExceptionMessageAndPattern

src/Common/Exception.cpp:464–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464PreformattedMessage getCurrentExceptionMessageAndPattern(
465 bool with_stacktrace,
466 bool check_embedded_stacktrace /*= false*/,
467 bool with_extra_info /*= true*/,
468 bool with_version /*= true*/)
469{
470 /// Explicitly block MEMORY_LIMIT_EXCEEDED
471 LockMemoryExceptionInThread lock_memory_tracker(VariableContext::Global);
472
473 WriteBufferFromOwnString stream;
474 std::string_view message_format_string;
475 std::vector<std::string> message_format_string_args;
476
477 try
478 {
479 throw;
480 }
481 catch (const Exception & e)
482 {
483 stream << getExceptionMessage(e, with_stacktrace, check_embedded_stacktrace)
484 << (with_extra_info ? getExtraExceptionInfo(e) : "");
485 if (with_version)
486 stream << " (version " << VERSION_STRING << VERSION_OFFICIAL << ")";
487 message_format_string = e.tryGetMessageFormatString();
488 message_format_string_args = e.getMessageFormatStringArgs();
489 }
490 catch (const Poco::Exception & e)
491 {
492 try
493 {
494 stream << "Poco::Exception. Code: " << ErrorCodes::POCO_EXCEPTION << ", e.code() = " << e.code()
495 << ", " << e.displayText()
496 << (with_stacktrace ? formatStackTraceSection(getExceptionStackTraceString(e)) : "")
497 << (with_extra_info ? getExtraExceptionInfo(e) : "");
498 if (with_version)
499 stream << " (version " << VERSION_STRING << VERSION_OFFICIAL << ")";
500 }
501 catch (...) {} // NOLINT(bugprone-empty-catch) Ok: best-effort exception formatting, must not throw
502 }
503 catch (const std::exception & e)
504 {
505 try
506 {
507 int status = 0;
508 auto name = demangle(typeid(e).name(), status);
509
510 if (status)
511 name += " (demangling status: " + toString(status) + ")";
512
513 stream << "std::exception. Code: " << ErrorCodes::STD_EXCEPTION << ", type: " << name << ", e.what() = " << e.what()
514 << (with_stacktrace ? formatStackTraceSection(getExceptionStackTraceString(e)) : "")
515 << (with_extra_info ? getExtraExceptionInfo(e) : "");
516 if (with_version)
517 stream << " (version " << VERSION_STRING << VERSION_OFFICIAL << ")";
518 }
519 catch (...) {} // NOLINT(bugprone-empty-catch) Ok: best-effort exception formatting, must not throw
520
521 if (debug_or_sanitizer_build || abort_on_logical_error.load(std::memory_order_relaxed))

Callers 15

processWithASTFuzzerMethod · 0.85
executeStepMethod · 0.85
handleRequestMethod · 0.85
tryLoadImplMethod · 0.85
catchFunction · 0.85
onFaultMethod · 0.85
reloadIfNewerMethod · 0.85
dropTableMethod · 0.85

Calls 15

getExtraExceptionInfoFunction · 0.85
formatStackTraceSectionFunction · 0.85
abortOnFailedAssertionFunction · 0.85
displayTextMethod · 0.80
getExceptionMessageFunction · 0.70
toStringFunction · 0.70
demangleFunction · 0.50
codeMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected