Skip to content

Commit ff90f53

Browse files
Add deserialization exception class
1 parent 8aa3d19 commit ff90f53

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/util/exception_utils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Author: Fotis Koutoulakis, [email protected]
88

99
#include "exception_utils.h"
1010

11+
#include <utility>
12+
1113
std::string invalid_user_input_exceptiont::what() const noexcept
1214
{
1315
std::string res;
@@ -18,3 +20,11 @@ std::string invalid_user_input_exceptiont::what() const noexcept
1820
res += correct_input + "\n";
1921
return res;
2022
}
23+
24+
deserialization_exceptiont::deserialization_exceptiont(std::string message)
25+
: message(std::move(message))
26+
{}
27+
28+
std::string deserialization_exceptiont::what() const noexcept {
29+
return message;
30+
}

src/util/exception_utils.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,13 @@ class system_exceptiont
5252
}
5353
};
5454

55+
class deserialization_exceptiont
56+
{
57+
public:
58+
explicit deserialization_exceptiont(std::string message);
59+
std::string what() const noexcept;
60+
private:
61+
std::string message;
62+
};
63+
5564
#endif // CPROVER_UTIL_EXCEPTION_UTILS_H

src/util/parse_options.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ int parse_options_baset::main()
8181
std::cerr << e.what() << "\n";
8282
return CPROVER_EXIT_EXCEPTION;
8383
}
84+
catch (const deserialization_exceptiont &e)
85+
{
86+
std::cerr << e.what() << '\n';
87+
return CPROVER_EXIT_EXCEPTION;
88+
}
8489

8590
return CPROVER_EXIT_SUCCESS;
8691
}

0 commit comments

Comments
 (0)