@@ -22,10 +22,12 @@ class ValidityError : public Exception {
2222
2323class NonDbcFileFormatError : public ValidityError {
2424public:
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- }
25+ explicit 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 ("
27+ + path + " ). Found the extension (" + extension + " )."
28+ ) { }
29+ explicit NonDbcFileFormatError (const std::string& error):
30+ error_msg(" File is not of DBC format. Cannot read this type of file (" + error + " )." ) { }
2931
3032 const char * what () const throw() override {
3133 return error_msg.c_str ();
@@ -35,32 +37,16 @@ class NonDbcFileFormatError : public ValidityError {
3537 std::string error_msg;
3638};
3739
38- class DbcFileIsMissingVersion : public ValidityError {
40+ class DbcFileIsMissingVersion : public NonDbcFileFormatError {
3941public:
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;
42+ explicit DbcFileIsMissingVersion (const std::string& line):
43+ NonDbcFileFormatError(" Invalid dbc file. Missing the required version header. Attempting to read line: (" + line + " )." ) { }
5044};
5145
52- class DbcFileIsMissingBitTiming : public ValidityError {
46+ class DbcFileIsMissingBitTiming : public NonDbcFileFormatError {
5347public:
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;
48+ explicit DbcFileIsMissingBitTiming (const std::string& line):
49+ NonDbcFileFormatError(" Invalid dbc file. Missing required bit timing in the header. Attempting to read line: (" + line + " )." ) { }
6450};
6551
6652} // libdbc
0 commit comments