mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 08:04:14 +02:00
parent
c9590d5183
commit
3c067e9547
@ -38,28 +38,31 @@ void __cxa_throw(void *obj, void *pvtinfo, void (*dest)(void *))
|
|||||||
void *thrown_ptr = obj;
|
void *thrown_ptr = obj;
|
||||||
const std::type_info *tinfo = static_cast<std::type_info *>(pvtinfo);
|
const std::type_info *tinfo = static_cast<std::type_info *>(pvtinfo);
|
||||||
const std::type_info *boost_exc = &typeid(boost::exception);
|
const std::type_info *boost_exc = &typeid(boost::exception);
|
||||||
|
const std::type_info *user_exc = &typeid(user_error);
|
||||||
|
|
||||||
/* Check if the exception is a pointer type. */
|
/* Check if the exception is a pointer type. */
|
||||||
if (tinfo->__is_pointer_p())
|
if (tinfo->__is_pointer_p())
|
||||||
thrown_ptr = *(void **)thrown_ptr;
|
thrown_ptr = *(void **)thrown_ptr;
|
||||||
|
|
||||||
|
if (!user_exc->__do_catch(tinfo, &thrown_ptr, 1)) {
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
|
StackTrace stack;
|
||||||
|
SetLastExceptionStack(stack);
|
||||||
|
|
||||||
StackTrace stack;
|
ContextTrace context;
|
||||||
SetLastExceptionStack(stack);
|
SetLastExceptionContext(context);
|
||||||
|
|
||||||
ContextTrace context;
|
|
||||||
SetLastExceptionContext(context);
|
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
/* Check if thrown_ptr inherits from boost::exception. */
|
/* Check if thrown_ptr inherits from boost::exception. */
|
||||||
if (boost_exc->__do_catch(tinfo, &thrown_ptr, 1)) {
|
if (boost_exc->__do_catch(tinfo, &thrown_ptr, 1)) {
|
||||||
boost::exception *ex = (boost::exception *)thrown_ptr;
|
boost::exception *ex = (boost::exception *)thrown_ptr;
|
||||||
|
|
||||||
if (boost::get_error_info<StackTraceErrorInfo>(*ex) == NULL)
|
if (boost::get_error_info<StackTraceErrorInfo>(*ex) == NULL)
|
||||||
*ex << StackTraceErrorInfo(stack);
|
*ex << StackTraceErrorInfo(stack);
|
||||||
|
|
||||||
if (boost::get_error_info<ContextTraceErrorInfo>(*ex) == NULL)
|
if (boost::get_error_info<ContextTraceErrorInfo>(*ex) == NULL)
|
||||||
*ex << ContextTraceErrorInfo(context);
|
*ex << ContextTraceErrorInfo(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class I2_BASE_API user_error : virtual public std::exception, virtual public boost::exception { };
|
||||||
|
|
||||||
I2_BASE_API StackTrace *GetLastExceptionStack(void);
|
I2_BASE_API StackTrace *GetLastExceptionStack(void);
|
||||||
I2_BASE_API void SetLastExceptionStack(const StackTrace& trace);
|
I2_BASE_API void SetLastExceptionStack(const StackTrace& trace);
|
||||||
|
|
||||||
@ -55,22 +57,24 @@ String DiagnosticInformation(const T& ex, StackTrace *stack = NULL, ContextTrace
|
|||||||
|
|
||||||
result << boost::diagnostic_information(ex);
|
result << boost::diagnostic_information(ex);
|
||||||
|
|
||||||
if (boost::get_error_info<StackTraceErrorInfo>(ex) == NULL) {
|
if (dynamic_cast<const user_error *>(&ex) == NULL) {
|
||||||
result << std::endl;
|
if (boost::get_error_info<StackTraceErrorInfo>(ex) == NULL) {
|
||||||
|
result << std::endl;
|
||||||
|
|
||||||
if (stack)
|
if (stack)
|
||||||
result << *stack;
|
result << *stack;
|
||||||
else
|
else
|
||||||
result << *GetLastExceptionStack();
|
result << *GetLastExceptionStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost::get_error_info<ContextTraceErrorInfo>(ex) == NULL) {
|
if (boost::get_error_info<ContextTraceErrorInfo>(ex) == NULL) {
|
||||||
result << std::endl;
|
result << std::endl;
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
result << *context;
|
result << *context;
|
||||||
else
|
else
|
||||||
result << *GetLastExceptionContext();
|
result << *GetLastExceptionContext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.str();
|
return result.str();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user