knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
KnowRobError.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #include <knowrob/KnowRobError.h>
7 #include <knowrob/Logger.h>
8 
9 using namespace knowrob;
10 
11 static inline std::string makeWhat(std::string_view exc_type, std::string_view exc_msg, std::string_view exc_trace) {
12  if (exc_trace.empty()) {
13  return fmt::format("{}: {}", exc_type, exc_msg);
14  } else {
15  return fmt::format("{}: {}\n{}", exc_type, exc_msg, exc_trace);
16  }
17 }
18 
19 KnowRobError::KnowRobError(std::string_view exc_type, std::string_view exc_msg)
20  : std::runtime_error(makeWhat(exc_type, exc_msg, "")), line_(0) {
21 }
22 
23 KnowRobError::KnowRobError(std::string_view exc_type, std::string_view exc_msg, std::string_view exc_trace)
24  : std::runtime_error(makeWhat(exc_type, exc_msg, exc_trace)), line_(0) {
25 }
26 
27 KnowRobError::KnowRobError(std::string_view exc_type, std::string_view exc_msg, std::string_view exc_file, int exc_line)
28  : std::runtime_error(makeWhat(exc_type, exc_msg, "")), file_(exc_file), line_(exc_line) {
29 }
30 
31 KnowRobError::KnowRobError(std::string_view exc_type, std::string_view exc_msg, std::string_view exc_file, int exc_line,
32  std::string_view exc_trace)
33  : std::runtime_error(makeWhat(exc_type, exc_msg, exc_trace)), file_(exc_file), line_(exc_line) {
34 }
KnowRobError(std::string_view exc_type, std::string_view msg)
TermRule & string()
Definition: terms.cpp:63