Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into 'python_bindings_host_load_plugin'
[simgrid.git] / src / simgrid / Exception.cpp
1 /* Copyright (c) 2018-2023. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include <simgrid/Exception.hpp>
7
8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ker_actor);
9
10 namespace simgrid {
11
12 // DO NOT define destructors for exceptions in Exception.hpp.
13 // Defining it here ensures that the exceptions are defined only in libsimgrid, but not in libsimgrid-java.
14 // Doing otherwise naturally breaks things (at least on freebsd with clang).
15 // TODO: is it still useful now that Java is gone?
16
17 Exception::~Exception()                             = default;
18 TimeoutException::~TimeoutException()               = default;
19 HostFailureException::~HostFailureException()       = default;
20 NetworkFailureException::~NetworkFailureException() = default;
21 StorageFailureException::~StorageFailureException() = default;
22 VmFailureException::~VmFailureException()           = default;
23 CancelException::~CancelException()                 = default;
24 TracingError::~TracingError()                       = default;
25 ParseError::~ParseError()                           = default;
26 AssertionError::~AssertionError()                   = default;
27 ForcefulKillException::~ForcefulKillException()     = default;
28
29 void ForcefulKillException::do_throw()
30 {
31   throw ForcefulKillException();
32 }
33
34 bool ForcefulKillException::try_n_catch(const std::function<void()>& try_block) // XBT_ATTRIB_DEPRECATED_v338
35 {
36   bool res;
37   try {
38     try_block();
39     res = true;
40   } catch (ForcefulKillException const& e) {
41     XBT_DEBUG("Caught a ForcefulKillException: %s", e.what());
42     res = false;
43   }
44   return res;
45 }
46 } // namespace simgrid