CARLA
Exception.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #ifdef LIBCARLA_NO_EXCEPTIONS
10 
11 namespace std {
12 
13  class exception;
14 
15 } // namespace std
16 
17 namespace carla {
18 
19  /// User define function, similar to Boost throw_exception.
20  ///
21  /// @important Boost exceptions are also routed to this function.
22  ///
23  /// When compiled with LIBCARLA_NO_EXCEPTIONS, this function is left undefined
24  /// in LibCarla, and the modules using LibCarla are expected to supply an
25  /// appropriate definition. Callers of throw_exception are allowed to assume
26  /// that the function never returns; therefore, if the user-defined
27  /// throw_exception returns, the behavior is undefined.
28  [[ noreturn ]] void throw_exception(const std::exception &e);
29 
30 } // namespace carla
31 
32 #else
33 
34 namespace carla {
35 
36  template <typename T>
37  [[ noreturn ]] void throw_exception(const T &e) {
38  throw e;
39  }
40 
41 } // namespace carla
42 
43 #endif // LIBCARLA_NO_EXCEPTIONS
void throw_exception(const T &e)
Definition: Exception.h:37
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133