Don't show stack traces for user errors.

Refs #5846
This commit is contained in:
Gunnar Beutner 2014-03-22 08:38:46 +01:00
parent c9590d5183
commit 3c067e9547
2 changed files with 32 additions and 25 deletions

View File

@ -38,12 +38,14 @@ void __cxa_throw(void *obj, void *pvtinfo, void (*dest)(void *))
void *thrown_ptr = obj;
const std::type_info *tinfo = static_cast<std::type_info *>(pvtinfo);
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. */
if (tinfo->__is_pointer_p())
thrown_ptr = *(void **)thrown_ptr;
#endif /* __APPLE__ */
if (!user_exc->__do_catch(tinfo, &thrown_ptr, 1)) {
#endif /* __APPLE__ */
StackTrace stack;
SetLastExceptionStack(stack);
@ -61,6 +63,7 @@ void __cxa_throw(void *obj, void *pvtinfo, void (*dest)(void *))
if (boost::get_error_info<ContextTraceErrorInfo>(*ex) == NULL)
*ex << ContextTraceErrorInfo(context);
}
}
#endif /* __APPLE__ */
real_cxa_throw(obj, pvtinfo, dest);

View File

@ -39,6 +39,8 @@
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 void SetLastExceptionStack(const StackTrace& trace);
@ -55,6 +57,7 @@ String DiagnosticInformation(const T& ex, StackTrace *stack = NULL, ContextTrace
result << boost::diagnostic_information(ex);
if (dynamic_cast<const user_error *>(&ex) == NULL) {
if (boost::get_error_info<StackTraceErrorInfo>(ex) == NULL) {
result << std::endl;
@ -72,6 +75,7 @@ String DiagnosticInformation(const T& ex, StackTrace *stack = NULL, ContextTrace
else
result << *GetLastExceptionContext();
}
}
return result.str();
}