1 /* ex - Exception Handling */
3 /* Copyright (c) 2005-2018. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
11 #include <xbt/backtrace.hpp>
12 #include "src/internal_config.h" /* execinfo when available */
16 #include "xbt/log.hpp"
17 #include "xbt/backtrace.h"
18 #include "xbt/backtrace.hpp"
19 #include "src/xbt_modinter.h" /* backtrace initialization headers */
21 #include "simgrid/sg_config.hpp" /* Configuration mechanism of SimGrid */
23 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_ex, xbt, "Exception mechanism");
25 // DO NOT define ~xbt_ex() in ex.hpp.
26 // Defining it here ensures that xbt_ex is defined only in libsimgrid, but not in libsimgrid-java.
27 // Doing otherwise naturally breaks things (at least on freebsd with clang).
29 xbt_ex::~xbt_ex() = default;
31 void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func)
33 xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func), message);
40 /** @brief shows an exception content and the associated stack if available */
41 void xbt_ex_display(xbt_ex_t * e)
43 simgrid::xbt::log_exception(xbt_log_priority_critical, "UNCAUGHT EXCEPTION", *e);
46 /** @brief returns a short name for the given exception category */
47 const char *xbt_ex_catname(xbt_errcat_t cat)
51 return "unknown error";
53 return "invalid argument";
55 return "out of bounds";
61 return "system error";
63 return "network error";
67 return "action canceled";
69 return "thread error";
73 return "tracing error";
79 return "INVALID ERROR";
81 return "INVALID ERROR";