dbc  ..
error.hpp
1 #ifndef ERROR_HPP
2 #define ERROR_HPP
3 
4 #include <exception>
5 #include <string>
6 
7 namespace Libdbc {
8 
9 class Exception : public std::exception {
10 public:
11  const char* what() const throw() override {
12  return "libdbc exception occurred";
13  }
14 };
15 
16 class ValidityError : public Exception {
17 public:
18  const char* what() const throw() override {
19  return "Invalid DBC file";
20  }
21 };
22 
24 public:
25  NonDbcFileFormatError(const std::string& path, const std::string& extension) {
26  error_msg = {"File is not of DBC format. Expected a .dbc extension. Cannot read this type of file (" + path + "). Found the extension (" + extension
27  + ")."};
28  }
29 
30  const char* what() const throw() override {
31  return error_msg.c_str();
32  }
33 
34 private:
35  std::string error_msg;
36 };
37 
39 public:
40  DbcFileIsMissingVersion(const std::string& line) {
41  error_msg = {"Invalid dbc file. Missing the required version header. Attempting to read line: (" + line + ")."};
42  }
43 
44  const char* what() const throw() override {
45  return error_msg.c_str();
46  }
47 
48 private:
49  std::string error_msg;
50 };
51 
53 public:
54  DbcFileIsMissingBitTiming(const std::string& line) {
55  error_msg = {"Invalid dbc file. Missing required bit timing in the header. Attempting to read line: (" + line + ")."};
56  }
57 
58  const char* what() const throw() override {
59  return error_msg.c_str();
60  }
61 
62 private:
63  std::string error_msg;
64 };
65 
66 } // libdbc
67 
68 #endif // ERROR_HPP
Definition: error.hpp:52
Definition: error.hpp:38
Definition: error.hpp:9
Definition: error.hpp:23
Definition: error.hpp:16