本文整理汇总了C++中Exception::getStackTrace方法的典型用法代码示例。如果您正苦于以下问题:C++ Exception::getStackTrace方法的具体用法?C++ Exception::getStackTrace怎么用?C++ Exception::getStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getStackTrace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getExceptionMessage
std::string getExceptionMessage(const Exception & e, bool with_stacktrace, bool check_embedded_stacktrace)
{
std::stringstream stream;
try
{
std::string text = e.displayText();
bool has_embedded_stack_trace = false;
if (check_embedded_stacktrace)
{
auto embedded_stack_trace_pos = text.find("Stack trace");
has_embedded_stack_trace = embedded_stack_trace_pos != std::string::npos;
if (!with_stacktrace && has_embedded_stack_trace)
{
text.resize(embedded_stack_trace_pos);
Poco::trimRightInPlace(text);
}
}
stream << "Code: " << e.code() << ", e.displayText() = " << text;
if (with_stacktrace && !has_embedded_stack_trace)
stream << ", Stack trace:\n\n" << e.getStackTrace().toString();
}
catch (...) {}
return stream.str();
}
示例2: log
void Logger::log(LogLevelType level, const char *type, const Exception &e,
const char *file /* = NULL */, int line /* = 0 */) {
if (!IsEnabled()) return;
std::string msg = type;
msg += e.getMessage();
if (file && file[0]) {
ostringstream os;
os << " in " << file << " on line " << line;
msg += os.str();
}
Log(level, msg, &e.getStackTrace());
}
示例3: writeException
void writeException(const Exception & e, WriteBuffer & buf, bool with_stack_trace)
{
writeBinary(e.code(), buf);
writeBinary(String(e.name()), buf);
writeBinary(e.displayText(), buf);
if (with_stack_trace)
writeBinary(e.getStackTrace().toString(), buf);
else
writeBinary(String(), buf);
bool has_nested = e.nested() != nullptr;
writeBinary(has_nested, buf);
if (has_nested)
writeException(Exception(Exception::CreateFromPoco, *e.nested()), buf, with_stack_trace);
}
示例4: callUserErrorHandler
bool ExecutionContext::callUserErrorHandler(const Exception &e, int64 errnum,
bool swallowExceptions) {
int errline = 0;
String errfile;
Array backtrace;
const ExtendedException *ee = dynamic_cast<const ExtendedException*>(&e);
if (ee) {
ArrayPtr arr = ee->getBackTrace();
if (arr) {
backtrace = *arr;
Array top = backtrace.rvalAt(0);
if (!top.isNull()) {
errfile = top.rvalAt("file");
errline = top.rvalAt("line").toInt64();
}
}
}
if (backtrace.isNull()) {
backtrace = stackTraceToBackTrace(e.getStackTrace());
}
bool retval = false;
RequestData::Data *data = s_request_data->data;
if (!data->systemExceptionHandlers.empty()) {
// Avoid calling the user error handler recursively
if (!data->insideUserHandler) {
data->insideUserHandler = true;
try {
if (!same(f_call_user_func_array
(data->systemExceptionHandlers.back(),
CREATE_VECTOR6(errnum, String(e.getMessage()), errfile,
errline, "", backtrace)),
false)) {
retval = true;
}
} catch (...) {
data->insideUserHandler = false;
if (!swallowExceptions) throw;
}
data->insideUserHandler = false;
}
}
return retval;
}
示例5: callUserErrorHandler
bool BaseExecutionContext::callUserErrorHandler(const Exception &e, int errnum,
bool swallowExceptions) {
switch (getErrorState()) {
case ExecutingUserHandler:
case ErrorRaisedByUserHandler:
return false;
default:
break;
}
if (!m_userErrorHandlers.empty() &&
(m_userErrorHandlers.back().second & errnum) != 0) {
int errline = 0;
String errfile;
Array backtrace;
const ExtendedException *ee = dynamic_cast<const ExtendedException*>(&e);
if (ee) {
ArrayPtr arr = ee->getBackTrace();
if (arr) {
backtrace = *arr;
Array top = backtrace.rvalAt(0);
if (!top.isNull()) {
errfile = top.rvalAt("file");
errline = top.rvalAt("line").toInt64();
}
}
}
if (backtrace.isNull()) {
backtrace = stackTraceToBackTrace(e.getStackTrace());
}
try {
ErrorStateHelper esh(this, ExecutingUserHandler);
if (!same(f_call_user_func_array
(m_userErrorHandlers.back().first,
CREATE_VECTOR6(errnum, String(e.getMessage()), errfile,
errline, "", backtrace)),
false)) {
return true;
}
} catch (...) {
if (!swallowExceptions) throw;
}
}
return false;
}