* Defines all possible exception that could occur in a SimGrid library.
*/
-#include <exception>
-#include <stdexcept>
-#include <string>
-#include <type_traits>
-#include <vector>
-
-#include <xbt/backtrace.h>
#include <xbt/backtrace.hpp>
-#include <xbt/base.h>
#include <xbt/ex.h>
-#include <xbt/log.h>
-#include <xbt/misc.h> // xbt_procname
-#include <xbt/virtu.h> // xbt_getpid
+
+#include <stdexcept>
+#include <string>
namespace simgrid {
namespace xbt {
/** Exception raised when something got canceled before completion */
class CancelException : public xbt_ex {
};
+
} // namespace simgrid
#endif
*/
#define THROWF(c, v, ...) _xbt_throw(bprintf(__VA_ARGS__), (xbt_errcat_t) c, v, __FILE__, __LINE__, __func__)
+XBT_ATTRIB_NORETURN void xbt_throw_impossible(const char* file, int line, const char* func);
/** Throw an exception because something impossible happened
* @ingroup XBT_ex_c
*/
-#define THROW_IMPOSSIBLE \
- THROWF(unknown_error, 0, "The Impossible Did Happen (yet again)")
+#define THROW_IMPOSSIBLE xbt_throw_impossible(__FILE__, __LINE__, __func__)
/** Throw an exception because something unimplemented stuff has been attempted
* @ingroup XBT_ex_c
*/
-#define THROW_UNIMPLEMENTED \
- THROWF(unknown_error, 0, "Function %s unimplemented",__func__)
-
-/** Throw an exception because some dead code was reached
- * @ingroup XBT_ex_c
- */
-#define THROW_DEADCODE \
- THROWF(unknown_error, 0, "Function %s was supposed to be DEADCODE, but it's not",__func__)
+XBT_ATTRIB_NORETURN void xbt_throw_unimplemented(const char* file, int line, const char* func);
+#define THROW_UNIMPLEMENTED xbt_throw_unimplemented(__FILE__, __LINE__, __func__)
/** Die because something impossible happened
* @ingroup XBT_ex_c
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <cstdlib>
-
-#include <atomic>
-#include <exception>
-#include <string>
-#include <typeinfo>
-#include <vector>
-#include <memory>
-#include <mutex>
-
#include "simgrid/Exception.hpp"
-#include <xbt/backtrace.hpp>
#include <xbt/config.hpp>
-#include <xbt/log.h>
#include <xbt/log.hpp>
+#include <mutex>
+#include <sstream>
+
XBT_LOG_EXTERNAL_CATEGORY(xbt);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_exception, xbt, "Exceptions");
}
} // namespace xbt
+} // namespace simgrid
+
+void xbt_throw_impossible(const char* file, int line, const char* func)
+{
+ std::stringstream ss;
+ ss << file << ":" << line << ":" << func << ": The Impossible Did Happen (yet again). Please report this bug.";
+ throw std::runtime_error(ss.str());
+}
+void xbt_throw_unimplemented(const char* file, int line, const char* func)
+{
+ std::stringstream ss;
+ ss << file << ":" << line << ":" << func << ": Feature unimplemented yet. Please report this bug.";
+ throw std::runtime_error(ss.str());
}