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:
27  : message_(static_cast<std::string>(message))
28  {}
29 
30  template <typename... SV>
31  BehaviorTreeException(const SV&... args) : message_(StrCat(args...))
32  {}
33 
34  const char* what() const noexcept
35  {
36  return message_.c_str();
37  }
38 
39 private:
40  std::string message_;
41 };
42 
43 // This errors are usually related to problems which "probably" require code refactoring
44 // to be fixed.
46 {
47 public:
49  {}
50 
51  template <typename... SV>
52  LogicError(const SV&... args) : BehaviorTreeException(args...)
53  {}
54 };
55 
56 // This errors are usually related to problems that are relted to data or conditions
57 // that happen only at run-time
59 {
60 public:
62  {}
63 
64  template <typename... SV>
65  RuntimeError(const SV&... args) : BehaviorTreeException(args...)
66  {}
67 };
68 
69 } // namespace BT
70 
71 #endif
BT
Definition: ex01_wrap_legacy.cpp:29
BT::BehaviorTreeException::BehaviorTreeException
BehaviorTreeException(std::string_view message)
Definition: exceptions.h:26
BT::RuntimeError::RuntimeError
RuntimeError(std::string_view message)
Definition: exceptions.h:61
BT::BehaviorTreeException
Definition: exceptions.h:23
BT::LogicError::LogicError
LogicError(const SV &... args)
Definition: exceptions.h:52
strcat.hpp
BT::LogicError
Definition: exceptions.h:45
BT::BehaviorTreeException::what
const char * what() const noexcept
Definition: exceptions.h:34
BT::BehaviorTreeException::message_
std::string message_
Definition: exceptions.h:40
BT::RuntimeError
Definition: exceptions.h:58
BT::LogicError::LogicError
LogicError(std::string_view message)
Definition: exceptions.h:48
BT::StrCat
std::string StrCat()
Definition: strcat.hpp:46
std
Definition: std.hpp:30
BT::RuntimeError::RuntimeError
RuntimeError(const SV &... args)
Definition: exceptions.h:65
lexy::_detail::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:184
BT::BehaviorTreeException::BehaviorTreeException
BehaviorTreeException(const SV &... args)
Definition: exceptions.h:31


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07