Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'dev-get-hostname-faster' into 'master'
[simgrid.git] / src / simgrid / Exception.cpp
1 /* Copyright (c) 2018-2022. 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
16 Exception::~Exception()                             = default;
17 TimeoutException::~TimeoutException()               = default;
18 HostFailureException::~HostFailureException()       = default;
19 NetworkFailureException::~NetworkFailureException() = default;
20 StorageFailureException::~StorageFailureException() = default;
21 VmFailureException::~VmFailureException()           = default;
22 CancelException::~CancelException()                 = default;
23 TracingError::~TracingError()                       = default;
24 ParseError::~ParseError()                           = default;
25 AssertionError::~AssertionError()                   = default;
26 ForcefulKillException::~ForcefulKillException()     = default;
27
28 void ForcefulKillException::do_throw()
29 {
30   throw ForcefulKillException();
31 }
32
33 bool ForcefulKillException::try_n_catch(const std::function<void()>& try_block)
34 {
35   bool res;
36   try {
37     try_block();
38     res = true;
39   } catch (ForcefulKillException const& e) {
40     XBT_DEBUG("Caught a ForcefulKillException: %s", e.what());
41     res = false;
42   }
43   return res;
44 }
45 } // namespace simgrid