1 /* Copyright (c) 2005-2018. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_XBT_EX_HPP
8 #define SIMGRID_XBT_EX_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 std::runtime_error, public simgrid::xbt::WithContextException {
31 std::runtime_error("")
36 * @param throwpoint Throw point (use XBT_THROW_POINT)
37 * @param message Exception message
39 xbt_ex(simgrid::xbt::ThrowPoint throwpoint, const char* message) :
40 std::runtime_error(message),
41 simgrid::xbt::WithContextException(throwpoint, simgrid::xbt::backtrace())
44 ~xbt_ex(); // DO NOT define it here -- see ex.cpp for a rationale
46 /** Category (what went wrong) */
47 xbt_errcat_t category = unknown_error;
49 /** Why did it went wrong */