Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 's_SimGrid_simgrid' into 'master'
[simgrid.git] / src / simgrid / Exception.cpp
1 /* Copyright (c) 2018-2020. 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(simix_context);
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 ForcefulKillException::~ForcefulKillException()     = default;
26
27 void ForcefulKillException::do_throw()
28 {
29   throw ForcefulKillException();
30 }
31
32 bool ForcefulKillException::try_n_catch(const std::function<void()>& try_block)
33 {
34   bool res;
35   try {
36     try_block();
37     res = true;
38   } catch (ForcefulKillException const&) {
39     XBT_DEBUG("Caught a ForcefulKillException");
40     res = false;
41   }
42   return res;
43 }
44 } // namespace simgrid