-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patherror.hpp
More file actions
54 lines (43 loc) · 1.48 KB
/
error.hpp
File metadata and controls
54 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef ERROR_HPP
#define ERROR_HPP
#include <exception>
#include <string>
namespace Libdbc {
class Exception : public std::exception {
public:
const char* what() const throw() override {
return "libdbc exception occurred";
}
};
class ValidityError : public Exception {
public:
const char* what() const throw() override {
return "Invalid DBC file";
}
};
class NonDbcFileFormatError : public ValidityError {
public:
explicit NonDbcFileFormatError(const std::string& path, const std::string& extension):
error_msg("File is not of DBC format. Expected a .dbc extension. Cannot read this type of file ("
+ path + "). Found the extension (" + extension + ")."
) { }
explicit NonDbcFileFormatError(const std::string& error):
error_msg("File is not of DBC format. Cannot read this type of file (" + error + ").") { }
const char* what() const throw() override {
return error_msg.c_str();
}
private:
std::string error_msg;
};
class DbcFileIsMissingVersion : public NonDbcFileFormatError {
public:
explicit DbcFileIsMissingVersion(const std::string& line):
NonDbcFileFormatError("Invalid dbc file. Missing the required version header. Attempting to read line: (" + line + ").") { }
};
class DbcFileIsMissingBitTiming : public NonDbcFileFormatError {
public:
explicit DbcFileIsMissingBitTiming(const std::string& line):
NonDbcFileFormatError("Invalid dbc file. Missing required bit timing in the header. Attempting to read line: (" + line + ").") { }
};
} // libdbc
#endif // ERROR_HPP