1 /* Copyright (c) 2005-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_XBT_EX_HPP
7 #define SIMGRID_XBT_EX_HPP
9 #include <simgrid/exception.hpp>
11 #include <xbt/exception.hpp>
15 /** A legacy exception
17 * It is defined by a category and a value within that category (as well as
18 * an optional error message).
20 * This used to be a structure for C exceptions but it has been retrofitted
21 * as a C++ exception and some of its data has been moved in the
22 * @ref WithContextException base class. We should deprecate it and replace it
23 * with either C++ different exceptions or `std::system_error` which already
24 * provides this (category + error code) logic.
28 class XBT_PUBLIC xbt_ex : public simgrid::exception, public simgrid::xbt::WithContextException {
30 xbt_ex() : simgrid::exception() {}
34 * @param throwpoint Throw point (use XBT_THROW_POINT)
35 * @param message Exception message
37 xbt_ex(simgrid::xbt::ThrowPoint throwpoint, const char* message)
38 : simgrid::exception(message), simgrid::xbt::WithContextException(throwpoint, simgrid::xbt::backtrace())
41 ~xbt_ex(); // DO NOT define it here -- see ex.cpp for a rationale
43 /** Category (what went wrong) */
44 xbt_errcat_t category = unknown_error;
46 /** Why did it went wrong */