exceptions.h
Go to the documentation of this file.
1 /* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2  * Copyright (C) 2018-2020 Davide Faconti, Eurecat - All Rights Reserved
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
11 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 */
13 
14 #ifndef BT_EXCEPTIONS_H
15 #define BT_EXCEPTIONS_H
16 
17 #include <string>
18 #include <stdexcept>
19 #include "utils/strcat.hpp"
20 
21 namespace BT
22 {
23 class BehaviorTreeException : public std::exception
24 {
25  public:
26 
27  BehaviorTreeException(nonstd::string_view message): message_(static_cast<std::string>(message))
28  {}
29 
30  template <typename... SV>
31  BehaviorTreeException(const SV&... args): message_(StrCat (args...))
32  { }
33 
34 
35  const char* what() const noexcept
36  {
37  return message_.c_str();
38  }
39 
40  private:
41  std::string message_;
42 };
43 
44 // This errors are usually related to problems that "probably" require code refactoring
45 // to be fixed.
47 {
48  public:
49  LogicError(nonstd::string_view message): BehaviorTreeException(message)
50  {}
51 
52  template <typename... SV>
53  LogicError(const SV&... args): BehaviorTreeException(args...)
54  { }
55 
56 };
57 
58 // This errors are usually related to problems that are relted to data or conditions
59 // that happen only at run-time
61 {
62  public:
63  RuntimeError(nonstd::string_view message): BehaviorTreeException(message)
64  {}
65 
66  template <typename... SV>
67  RuntimeError(const SV&... args): BehaviorTreeException(args...)
68  { }
69 };
70 
71 
72 }
73 
74 #endif
Definition: any.hpp:455
LogicError(nonstd::string_view message)
Definition: exceptions.h:49
BehaviorTreeException(nonstd::string_view message)
Definition: exceptions.h:27
RuntimeError(const SV &...args)
Definition: exceptions.h:67
std::string StrCat()
Definition: strcat.hpp:47
BehaviorTreeException(const SV &...args)
Definition: exceptions.h:31
LogicError(const SV &...args)
Definition: exceptions.h:53
const char * what() const noexcept
Definition: exceptions.h:35
RuntimeError(nonstd::string_view message)
Definition: exceptions.h:63


behaviotree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Tue May 4 2021 02:56:24