Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to pass a std::string as message to Exceptions
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 25 Aug 2018 13:32:58 +0000 (15:32 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 25 Aug 2018 13:32:58 +0000 (15:32 +0200)
include/simgrid/Exception.hpp
src/simix/ActorImpl.cpp
src/xbt/exception.cpp

index 56eef78..e09cde0 100644 (file)
@@ -61,7 +61,7 @@ public:
 /** Ancestor class of all SimGrid exception */
 class Exception : public std::runtime_error {
 public:
-  Exception(simgrid::xbt::ThrowPoint throwpoint, const char* message)
+  Exception(simgrid::xbt::ThrowPoint throwpoint, std::string message)
       : std::runtime_error(message), throwpoint_(throwpoint)
   {
   }
@@ -95,7 +95,7 @@ public:
    * @param throwpoint Throw point (use XBT_THROW_POINT)
    * @param message    Exception message
    */
-  xbt_ex(simgrid::xbt::ThrowPoint throwpoint, const char* message) : simgrid::Exception(throwpoint, message) {}
+  xbt_ex(simgrid::xbt::ThrowPoint throwpoint, std::string message) : simgrid::Exception(throwpoint, message) {}
 
   ~xbt_ex(); // DO NOT define it here -- see ex.cpp for a rationale
 
@@ -115,7 +115,7 @@ class TimeoutError : public xbt_ex {
 /** Exception raised when an host fails */
 class HostFailureException : public xbt_ex {
 public:
-  HostFailureException(simgrid::xbt::ThrowPoint throwpoint, const char* message) : xbt_ex(throwpoint, message)
+  HostFailureException(simgrid::xbt::ThrowPoint throwpoint, std::string message) : xbt_ex(throwpoint, message)
   {
     category = host_error;
   }
index 2f2b67c..f8c6f8a 100644 (file)
@@ -229,7 +229,8 @@ void ActorImpl::resume()
 smx_activity_t ActorImpl::sleep(double duration)
 {
   if (host_->is_off())
-    THROWF(host_error, 0, "Host %s failed, you cannot sleep there.", host_->get_cname());
+    throw new simgrid::HostFailureException(XBT_THROW_POINT,
+        std::string("Host ") + std::string(host_->get_cname())+" failed, you cannot sleep there.");
 
   simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl();
   synchro->host                                 = host_;
index 9ab411a..d2712ee 100644 (file)
@@ -30,8 +30,7 @@ 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, simgrid::xbt::backtrace(), xbt_procname(), xbt_getpid()),
-           message);
+  xbt_ex e(simgrid::xbt::ThrowPoint(XBT_THROW_POINT), message);
   xbt_free(message);
   e.category = errcat;
   e.value    = value;