Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
merge xbt/ex.hpp into simgrid/exception.hpp
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 24 Aug 2018 16:32:02 +0000 (18:32 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 24 Aug 2018 20:40:30 +0000 (22:40 +0200)
44 files changed:
examples/s4u/app-bittorrent/s4u-peer.cpp
examples/s4u/dht-chord/s4u-dht-chord.hpp
examples/s4u/exec-ptask/s4u-exec-ptask.cpp
examples/s4u/platform-failures/s4u-platform-failures.cpp
examples/simdag/test/sd_test.cpp
include/simgrid/exception.hpp
include/simgrid/s4u.hpp
include/xbt/ex.hpp [deleted file]
src/bindings/java/JavaContext.cpp
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg_process.cpp
src/bindings/java/jmsg_synchro.cpp
src/bindings/java/jmsg_vm.cpp
src/kernel/activity/ConditionVariableImpl.cpp
src/kernel/activity/SleepImpl.cpp
src/msg/msg_gos.cpp
src/msg/msg_synchro.cpp
src/plugins/vm/VmLiveMigration.cpp
src/s4u/s4u_Barrier.cpp
src/s4u/s4u_ConditionVariable.cpp
src/simix/ActorImpl.cpp
src/simix/smx_deployment.cpp
src/simix/smx_environment.cpp
src/simix/smx_host.cpp
src/simix/smx_io.cpp
src/simix/smx_network.cpp
src/smpi/mpi/smpi_info.cpp
src/smpi/mpi/smpi_request.cpp
src/xbt/config.cpp
src/xbt/cunit.cpp
src/xbt/dict.cpp
src/xbt/dynar.cpp
src/xbt/ex.cpp [deleted file]
src/xbt/exception.cpp
src/xbt/xbt_os_synchro.cpp
src/xbt/xbt_replay.cpp
src/xbt/xbt_str.cpp
teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp
teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp
teshsuite/msg/task_progress/task_progress.cpp
teshsuite/s4u/actor-autorestart/actor-autorestart.cpp
teshsuite/s4u/host_on_off_wait/host_on_off_wait.cpp
teshsuite/xbt/mmalloc/mmalloc_test.cpp
tools/cmake/DefinePackages.cmake

index 21fefba..71a98e3 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <algorithm>
 #include <climits>
-#include <xbt/ex.hpp>
 
 #include "s4u-peer.hpp"
 #include "s4u-tracker.hpp"
index ea6e86b..8fca9e6 100644 (file)
@@ -8,7 +8,6 @@
 #include "simgrid/s4u.hpp"
 #include <string>
 #include <xbt/RngStream.h>
-#include <xbt/ex.hpp>
 #include <xbt/str.h>
 
 #define MAX_SIMULATION_TIME 1000
index ef3bac1..e5b9b6b 100644 (file)
@@ -20,8 +20,6 @@
 
 #include "simgrid/plugins/energy.h"
 #include <simgrid/s4u.hpp>
-#include <xbt/ex.hpp>
-#include <xbt/log.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_energyptask, "Messages specific for this s4u example");
 
index df3b9fa..22c4d24 100644 (file)
@@ -4,7 +4,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u.hpp"
-#include "xbt/ex.hpp"
 #include "xbt/str.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
index 3e5822b..89e1a9f 100644 (file)
@@ -5,11 +5,9 @@
 
 #include "simgrid/s4u.hpp"
 #include "simgrid/simdag.h"
-#include "xbt/ex.h"
-#include "xbt/log.h"
+
 #include <cmath>
 #include <set>
-#include <xbt/ex.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, "Logging specific to this SimDag example");
 
index bab34d8..32edcea 100644 (file)
  */
 
 #include <exception>
+#include <simgrid/exception.hpp>
+#include <stdexcept>
+#include <xbt/exception.hpp>
+
+#include <xbt/ex.h>
 
 namespace simgrid {
 
@@ -35,9 +40,45 @@ class network_failure : public simgrid::exception {
 };
 
 /** Exception raised when something got canceled before completion */
-class cancel_error : public simgrid::exception {
+class canceled_error : public simgrid::exception {
 };
 
 } // namespace simgrid
 
+/** A legacy exception
+ *
+ *  It is defined by a category and a value within that category (as well as
+ *  an optional error message).
+ *
+ *  This used to be a structure for C exceptions but it has been retrofitted
+ *  as a C++ exception and some of its data has been moved in the
+ *  @ref WithContextException base class. We should deprecate it and replace it
+ *  with either C++ different exceptions or `std::system_error` which already
+ *  provides this (category + error code) logic.
+ *
+ *  @ingroup XBT_ex_c
+ */
+class XBT_PUBLIC xbt_ex : public simgrid::exception, public simgrid::xbt::WithContextException {
+public:
+  xbt_ex() : simgrid::exception() {}
+
+  /**
+   *
+   * @param throwpoint Throw point (use XBT_THROW_POINT)
+   * @param message    Exception message
+   */
+  xbt_ex(simgrid::xbt::ThrowPoint throwpoint, const char* message)
+      : simgrid::exception(message), simgrid::xbt::WithContextException(throwpoint, simgrid::xbt::backtrace())
+  {
+  }
+
+  ~xbt_ex(); // DO NOT define it here -- see ex.cpp for a rationale
+
+  /** Category (what went wrong) */
+  xbt_errcat_t category = unknown_error;
+
+  /** Why did it went wrong */
+  int value = 0;
+};
+
 #endif
index cd02cf1..42a72bf 100644 (file)
@@ -20,4 +20,6 @@
 #include <simgrid/s4u/NetZone.hpp>
 #include <simgrid/s4u/Storage.hpp>
 
+#include <simgrid/exception.hpp>
+
 #endif /* SIMGRID_S4U_S4U_H */
diff --git a/include/xbt/ex.hpp b/include/xbt/ex.hpp
deleted file mode 100644 (file)
index 927790d..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright (c) 2005-2018. The SimGrid Team. All rights reserved.          */
-
-/* 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. */
-
-#ifndef SIMGRID_XBT_EX_HPP
-#define SIMGRID_XBT_EX_HPP
-
-#include <simgrid/exception.hpp>
-#include <stdexcept>
-#include <xbt/exception.hpp>
-
-#include <xbt/ex.h>
-
-/** A legacy exception
- *
- *  It is defined by a category and a value within that category (as well as
- *  an optional error message).
- *
- *  This used to be a structure for C exceptions but it has been retrofitted
- *  as a C++ exception and some of its data has been moved in the
- *  @ref WithContextException base class. We should deprecate it and replace it
- *  with either C++ different exceptions or `std::system_error` which already
- *  provides this (category + error code) logic.
- *
- *  @ingroup XBT_ex_c
- */
-class XBT_PUBLIC xbt_ex : public simgrid::exception, public simgrid::xbt::WithContextException {
-public:
-  xbt_ex() : simgrid::exception() {}
-
-  /**
-   *
-   * @param throwpoint Throw point (use XBT_THROW_POINT)
-   * @param message    Exception message
-   */
-  xbt_ex(simgrid::xbt::ThrowPoint throwpoint, const char* message)
-      : simgrid::exception(message), simgrid::xbt::WithContextException(throwpoint, simgrid::xbt::backtrace())
-  {}
-
-  ~xbt_ex(); // DO NOT define it here -- see ex.cpp for a rationale
-
-  /** Category (what went wrong) */
-  xbt_errcat_t category = unknown_error;
-
-  /** Why did it went wrong */
-  int value = 0;
-
-};
-
-#endif
index e602914..3cf2422 100644 (file)
@@ -7,8 +7,8 @@
 
 #include "JavaContext.hpp"
 #include "jxbt_utilities.hpp"
+#include "simgrid/exception.hpp"
 #include "src/simix/smx_private.hpp"
-#include "xbt/ex.hpp"
 
 #include <functional>
 #include <utility>
index 6e5cbdd..a6db169 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "JavaContext.hpp"
 
-#include <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 
 /* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
 #ifndef JNIEXPORT
index 2c392a7..fc5444c 100644 (file)
@@ -5,7 +5,7 @@
 /* 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 <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 
 #include "jmsg_process.h"
 
index 259def3..b8afdec 100644 (file)
@@ -5,7 +5,7 @@
 /* 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 <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 
 #include "jmsg.hpp"
 #include "jmsg_synchro.h"
index 6bdf53e..fb3bfbb 100644 (file)
@@ -8,9 +8,9 @@
 #include "jmsg_vm.h"
 #include "jmsg_host.h"
 #include "jxbt_utilities.hpp"
+#include "simgrid/exception.hpp"
 #include "simgrid/plugins/live_migration.h"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "xbt/ex.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
 
index ddd34cd..20412aa 100644 (file)
@@ -4,10 +4,10 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/activity/ConditionVariableImpl.hpp"
+#include "simgrid/exception.hpp"
 #include "src/kernel/activity/MutexImpl.hpp"
 #include "src/kernel/activity/SynchroRaw.hpp"
 #include "src/simix/smx_synchro_private.hpp"
-#include "xbt/ex.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ConditionVariable, simix_synchro, "Condition variables");
 
index b02cda8..38d4cb3 100644 (file)
@@ -9,11 +9,11 @@
 #include "src/kernel/activity/SleepImpl.hpp"
 #include "src/kernel/context/Context.hpp"
 
+#include "simgrid/exception.hpp"
 #include "src/simix/ActorImpl.hpp"
 #include "src/simix/popping_private.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/surf/surf_interface.hpp"
-#include "xbt/ex.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
index 84d1c06..b32a3a6 100644 (file)
@@ -3,7 +3,7 @@
 /* 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 <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 
 #include "simgrid/s4u/Mailbox.hpp"
 #include "src/instr/instr_private.hpp"
index 99290b1..9bd5a7d 100644 (file)
@@ -3,9 +3,8 @@
 /* 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 "xbt/ex.hpp"
-
 #include "msg_private.hpp"
+#include "simgrid/exception.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/simix/smx_synchro_private.hpp"
 #include "xbt/synchro.h"
index 72eadf5..a9a3fd6 100644 (file)
@@ -4,10 +4,10 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/plugins/vm/VmLiveMigration.hpp"
+#include "simgrid/exception.hpp"
 #include "src/instr/instr_private.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include "src/plugins/vm/VmHostExt.hpp"
-#include "xbt/ex.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(vm_live_migration, "S4U virtual machines live migration");
 
index a8ce588..b0c2121 100644 (file)
@@ -6,7 +6,7 @@
 #include <exception>
 #include <mutex>
 
-#include <xbt/ex.hpp>
+#include <xbt/exception.hpp>
 #include <xbt/log.hpp>
 
 #include "simgrid/barrier.h"
index 2a08728..7707e66 100644 (file)
@@ -6,7 +6,7 @@
 #include <exception>
 #include <mutex>
 
-#include <xbt/ex.hpp>
+#include <xbt/exception.hpp>
 #include <xbt/log.hpp>
 
 #include "simgrid/s4u/ConditionVariable.hpp"
index 8c60d57..f7dad67 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "mc/mc.h"
+#include "simgrid/exception.hpp"
 #include "smx_private.hpp"
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
@@ -17,7 +18,6 @@
 #include "src/simix/smx_synchro_private.hpp"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
-#include "xbt/ex.hpp"
 
 #ifdef HAVE_SMPI
 #include "src/smpi/include/private.hpp"
index 2226ad9..96f1fb7 100644 (file)
@@ -7,7 +7,7 @@
 #include "smx_private.hpp"
 #include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
 #include <simgrid/engine.h>
-#include <xbt/ex.hpp>
+#include <simgrid/exception.hpp>
 
 #include <string>
 #include <vector>
index dde40f2..1537e99 100644 (file)
@@ -8,7 +8,7 @@
 #include "xbt/xbt_os_time.h"
 
 #include <simgrid/engine.h>
-#include <xbt/ex.hpp>
+#include <simgrid/exception.hpp>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix, "Logging specific to SIMIX (environment)");
 
index dc7f150..eac34bf 100644 (file)
@@ -4,13 +4,13 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "mc/mc.h"
+#include "simgrid/exception.hpp"
 #include "smx_private.hpp"
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include "src/simix/smx_host_private.hpp"
-#include "xbt/ex.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "SIMIX hosts");
 
index 98d4b23..af80dc9 100644 (file)
@@ -4,9 +4,9 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "mc/mc.h"
+#include "simgrid/exception.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Io.hpp"
-#include "xbt/ex.hpp"
 
 #include "smx_private.hpp"
 #include "src/kernel/activity/IoImpl.hpp"
index a295cae..fbcea71 100644 (file)
@@ -4,12 +4,12 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "mc/mc.h"
+#include "simgrid/exception.hpp"
 #include "src/kernel/activity/MailboxImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/network_interface.hpp"
-#include "xbt/ex.hpp"
 
 #include <boost/circular_buffer.hpp>
 #include <boost/range/algorithm.hpp>
index 9ac105a..16b8c53 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "smpi_info.hpp"
-#include "xbt/ex.hpp"
+#include "simgrid/exception.hpp"
 #include "xbt/sysdep.h"
 
 namespace simgrid{
index 4a76651..16b0dd5 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "mc/mc.h"
 #include "private.hpp"
+#include "simgrid/exception.hpp"
 #include "simgrid/s4u/Exec.hpp"
 #include "smpi_comm.hpp"
 #include "smpi_datatype.hpp"
@@ -17,7 +18,6 @@
 #include "src/simix/ActorImpl.hpp"
 #include "src/smpi/include/smpi_actor.hpp"
 #include "xbt/config.hpp"
-#include <xbt/ex.hpp>
 
 #include <algorithm>
 
index 3d12053..b69e80f 100644 (file)
@@ -19,6 +19,7 @@
 #include <typeinfo>
 #include <vector>
 
+#include "simgrid/exception.hpp"
 #include "simgrid/sg_config.hpp"
 #include "xbt/dynar.h"
 #include "xbt/log.h"
@@ -26,7 +27,6 @@
 #include "xbt/sysdep.h"
 #include <xbt/config.h>
 #include <xbt/config.hpp>
-#include <xbt/ex.hpp>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
 
@@ -719,9 +719,9 @@ int xbt_cfg_get_boolean(const char *key)
 
 #include <string>
 
+#include "simgrid/exception.hpp"
 #include "xbt.h"
 #include "xbt/ex.h"
-#include <xbt/ex.hpp>
 
 #include <xbt/config.hpp>
 
index 95b4d95..586173e 100644 (file)
@@ -14,8 +14,8 @@
 #include <string>
 #include <vector>
 
+#include "simgrid/exception.hpp"
 #include <xbt/cunit.h>
-#include <xbt/ex.hpp>
 #include <xbt/string.hpp>
 
 /* output stream to use everywhere */
index cac4d27..1a6b61e 100644 (file)
@@ -6,13 +6,13 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/dict.h"
+#include "dict_private.h"
+#include "simgrid/exception.hpp"
+#include "src/xbt_modinter.h"
 #include "xbt/ex.h"
-#include <xbt/ex.hpp>
 #include "xbt/log.h"
 #include "xbt/mallocator.h"
-#include "src/xbt_modinter.h"
 #include "xbt/str.h"
-#include "dict_private.h"
 
 #include <cstdio>
 #include <cstring>
@@ -454,11 +454,11 @@ void xbt_dict_postexit()
 }
 
 #ifdef SIMGRID_TEST
+#include "simgrid/exception.hpp"
 #include "src/internal_config.h"
 #include "xbt.h"
 #include "xbt/ex.h"
 #include <ctime>
-#include <xbt/ex.hpp>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_dict);
 
index ff95c55..e1444f0 100644 (file)
@@ -6,12 +6,12 @@
 /* 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 "xbt/dynar.h"
+#include "simgrid/exception.hpp"
+#include "xbt/ex.h"
+#include "xbt/log.h"
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "xbt/ex.h"
-#include <xbt/ex.hpp>
-#include "xbt/dynar.h"
 #include <sys/types.h>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dyn, xbt, "Dynamic arrays");
diff --git a/src/xbt/ex.cpp b/src/xbt/ex.cpp
deleted file mode 100644 (file)
index 76f0837..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ex - Exception Handling                                                  */
-
-/* Copyright (c) 2005-2018. The SimGrid Team. All rights reserved.          */
-
-/* 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 <cstdio>
-#include <cstdlib>
-
-#include <xbt/backtrace.hpp>
-#include "src/internal_config.h"           /* execinfo when available */
-#include "xbt/ex.h"
-#include <xbt/ex.hpp>
-#include "xbt/log.h"
-#include "xbt/log.hpp"
-#include "xbt/backtrace.h"
-#include "xbt/backtrace.hpp"
-#include "src/xbt_modinter.h"       /* backtrace initialization headers */
-
-#include "simgrid/sg_config.hpp" /* Configuration mechanism of SimGrid */
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_ex, xbt, "Exception mechanism");
-
-// DO NOT define ~xbt_ex() in ex.hpp.
-// Defining it here ensures that xbt_ex is defined only in libsimgrid, but not in libsimgrid-java.
-// Doing otherwise naturally breaks things (at least on freebsd with clang).
-
-xbt_ex::~xbt_ex() = default;
-
-void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func)
-{
-  xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func), message);
-  xbt_free(message);
-  e.category = errcat;
-  e.value = value;
-  throw e;
-}
-
-/** @brief shows an exception content and the associated stack if available */
-void xbt_ex_display(xbt_ex_t * e)
-{
-  simgrid::xbt::log_exception(xbt_log_priority_critical, "UNCAUGHT EXCEPTION", *e);
-}
-
-/** @brief returns a short name for the given exception category */
-const char *xbt_ex_catname(xbt_errcat_t cat)
-{
-  switch (cat) {
-  case unknown_error:
-    return "unknown error";
-  case arg_error:
-    return "invalid argument";
-  case bound_error:
-    return "out of bounds";
-  case mismatch_error:
-    return "mismatch";
-  case not_found_error:
-    return "not found";
-  case system_error:
-    return "system error";
-  case network_error:
-    return "network error";
-  case timeout_error:
-    return "timeout";
-  case cancel_error:
-    return "action canceled";
-  case thread_error:
-    return "thread error";
-  case host_error:
-    return "host failed";
-  case tracing_error:
-    return "tracing error";
-  case io_error:
-    return "io error";
-  case vm_error:
-    return "vm error";
-  default:
-    return "INVALID ERROR";
-  }
-  return "INVALID ERROR";
-}
index 9d5ad43..dbfd17f 100644 (file)
 #include <memory>
 #include <mutex>
 
+#include "simgrid/exception.hpp"
 #include <xbt/backtrace.hpp>
 #include <xbt/config.hpp>
-#include <xbt/ex.hpp>
-#include <xbt/exception.hpp>
 #include <xbt/log.h>
 #include <xbt/log.hpp>
 
 XBT_LOG_EXTERNAL_CATEGORY(xbt);
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_exception, xbt, "Exceptions");
 
+// DO NOT define ~xbt_ex() in exception.hpp.
+// Defining it here ensures that xbt_ex is defined only in libsimgrid, but not in libsimgrid-java.
+// Doing otherwise naturally breaks things (at least on freebsd with clang).
+
+xbt_ex::~xbt_ex() = default;
+
+void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func)
+{
+  xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func), message);
+  xbt_free(message);
+  e.category = errcat;
+  e.value    = value;
+  throw e;
+}
+
+/** @brief shows an exception content and the associated stack if available */
+void xbt_ex_display(xbt_ex_t* e)
+{
+  simgrid::xbt::log_exception(xbt_log_priority_critical, "UNCAUGHT EXCEPTION", *e);
+}
+
+/** @brief returns a short name for the given exception category */
+const char* xbt_ex_catname(xbt_errcat_t cat)
+{
+  switch (cat) {
+    case unknown_error:
+      return "unknown error";
+    case arg_error:
+      return "invalid argument";
+    case bound_error:
+      return "out of bounds";
+    case mismatch_error:
+      return "mismatch";
+    case not_found_error:
+      return "not found";
+    case system_error:
+      return "system error";
+    case network_error:
+      return "network error";
+    case timeout_error:
+      return "timeout";
+    case cancel_error:
+      return "action canceled";
+    case thread_error:
+      return "thread error";
+    case host_error:
+      return "host failed";
+    case tracing_error:
+      return "tracing error";
+    case io_error:
+      return "io error";
+    case vm_error:
+      return "vm error";
+    default:
+      return "INVALID ERROR";
+  }
+  return "INVALID ERROR";
+}
+
 namespace simgrid {
 namespace xbt {
 
index eaab5a6..d1d8b0a 100644 (file)
@@ -6,9 +6,9 @@
 /* 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 "simgrid/exception.hpp"
 #include "simgrid/simix.h" /* used implementation */
 #include "src/kernel/activity/ConditionVariableImpl.hpp"
-#include "xbt/ex.hpp"
 #include "xbt/synchro.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism");
index af68627..3a876d0 100644 (file)
@@ -3,7 +3,7 @@
 /* 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 "xbt/ex.hpp"
+#include "simgrid/exception.hpp"
 #include "xbt/log.h"
 #include "xbt/replay.hpp"
 
index b0ab069..b530055 100644 (file)
@@ -1,15 +1,14 @@
-/* xbt_str.cpp - various helping functions to deal with strings               */
+/* xbt_str.cpp - various helping functions to deal with strings             */
 
-/* Copyright (c) 2007-2018. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved.          */
 
 /* 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 <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 #include "xbt/misc.h"
+#include "xbt/str.h" /* headers of these functions */
 #include "xbt/sysdep.h"
-#include "xbt/str.h"            /* headers of these functions */
 
 /** @brief Splits a string into a dynar of strings
  *
@@ -264,7 +263,7 @@ double xbt_str_parse_double(const char* str, const char* error_msg)
 }
 
 #ifdef SIMGRID_TEST
-#include <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 #include "xbt/str.h"
 
 XBT_TEST_SUITE("xbt_str", "String Handling");
index 8f0b5b2..278c103 100644 (file)
@@ -3,8 +3,8 @@
 /* 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 "simgrid/exception.hpp"
 #include "simgrid/msg.h"
-#include <xbt/ex.hpp>
 
 #include <stdio.h> /* sscanf */
 
index 035e1f6..a7659a9 100644 (file)
@@ -3,7 +3,7 @@
 /* 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 <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 #include "simgrid/msg.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
index 3971b80..0596850 100644 (file)
@@ -3,11 +3,9 @@
 /* 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 <xbt/ex.hpp>
+#include "simgrid/exception.hpp"
 #include "simgrid/msg.h"
 
-#include <stdio.h> /* snprintf */
-
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 static std::vector<msg_task_t> tasks = std::vector<msg_task_t>();
index 47e132a..00eee52 100644 (file)
@@ -4,7 +4,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u.hpp"
-#include <xbt/ex.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
 
index 0ee7ad1..45ed6d3 100644 (file)
@@ -4,7 +4,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u.hpp"
-#include <xbt/ex.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
 
index 5c9d4be..e05d3ff 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2018. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2018. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -14,7 +13,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include <xbt/ex.hpp>
+#include <simgrid/exception.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"this test");
 
index d12bd14..d674ddc 100644 (file)
@@ -275,7 +275,6 @@ set(XBT_SRC
   src/xbt/dict_cursor.c
   src/xbt/dict_elm.c
   src/xbt/dynar.cpp
-  src/xbt/ex.cpp
   src/xbt/exception.cpp
   src/xbt/graph.c
   src/xbt/log.c
@@ -750,7 +749,6 @@ set(headers_to_install
   include/xbt/dict.h
   include/xbt/dynar.h
   include/xbt/ex.h
-  include/xbt/ex.hpp
   include/xbt/exception.hpp
   include/xbt/Extendable.hpp
   include/xbt/file.hpp