-
Notifications
You must be signed in to change notification settings - Fork 274
Exception utils: remove redundant what() implementations #6608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tautschnig
merged 1 commit into
diffblue:develop
from
tautschnig:cleanup/exception-utils
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ Author: Daniel Kroening, [email protected] | |
#ifndef CPROVER_SOLVERS_SMT2_SMT2_TOKENIZER_H | ||
#define CPROVER_SOLVERS_SMT2_SMT2_TOKENIZER_H | ||
|
||
#include <util/exception_utils.h> | ||
|
||
#include <sstream> | ||
#include <string> | ||
|
||
|
@@ -23,7 +21,7 @@ class smt2_tokenizert | |
line_no=1; | ||
} | ||
|
||
class smt2_errort : public cprover_exception_baset | ||
class smt2_errort | ||
{ | ||
public: | ||
smt2_errort(const std::string &_message, unsigned _line_no) | ||
|
@@ -36,7 +34,7 @@ class smt2_tokenizert | |
{ | ||
} | ||
|
||
std::string what() const override | ||
std::string what() const | ||
{ | ||
return message.str(); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,11 @@ Author: Fotis Koutoulakis, [email protected] | |
#include "exception_utils.h" | ||
#include <utility> | ||
|
||
std::string cprover_exception_baset::what() const | ||
{ | ||
return reason; | ||
} | ||
|
||
std::string invalid_command_line_argument_exceptiont::what() const | ||
{ | ||
std::string res; | ||
|
@@ -28,42 +33,32 @@ invalid_command_line_argument_exceptiont:: | |
std::string reason, | ||
std::string option, | ||
std::string correct_input) | ||
: reason(std::move(reason)), | ||
: cprover_exception_baset(std::move(reason)), | ||
option(std::move(option)), | ||
correct_input(std::move(correct_input)) | ||
{ | ||
} | ||
|
||
system_exceptiont::system_exceptiont(std::string message) | ||
: message(std::move(message)) | ||
: cprover_exception_baset(std::move(message)) | ||
{ | ||
} | ||
|
||
std::string system_exceptiont::what() const | ||
{ | ||
return message; | ||
} | ||
|
||
deserialization_exceptiont::deserialization_exceptiont(std::string message) | ||
: message(std::move(message)) | ||
: cprover_exception_baset(std::move(message)) | ||
{ | ||
} | ||
|
||
std::string deserialization_exceptiont::what() const | ||
{ | ||
return message; | ||
} | ||
|
||
incorrect_goto_program_exceptiont::incorrect_goto_program_exceptiont( | ||
std::string message) | ||
: message(std::move(message)) | ||
: cprover_exception_baset(std::move(message)), | ||
source_location(source_locationt::nil()) | ||
{ | ||
source_location.make_nil(); | ||
} | ||
|
||
std::string incorrect_goto_program_exceptiont::what() const | ||
{ | ||
std::string ret(message); | ||
std::string ret(reason); | ||
|
||
if(!source_location.is_nil()) | ||
ret += " (at: " + source_location.as_string() + ")"; | ||
|
@@ -76,32 +71,17 @@ std::string incorrect_goto_program_exceptiont::what() const | |
|
||
unsupported_operation_exceptiont::unsupported_operation_exceptiont( | ||
std::string message) | ||
: message(std::move(message)) | ||
: cprover_exception_baset(std::move(message)) | ||
{ | ||
} | ||
|
||
std::string unsupported_operation_exceptiont::what() const | ||
{ | ||
return message; | ||
} | ||
|
||
analysis_exceptiont::analysis_exceptiont(std::string reason) | ||
: reason(std::move(reason)) | ||
{ | ||
} | ||
|
||
std::string analysis_exceptiont::what() const | ||
: cprover_exception_baset(std::move(reason)) | ||
{ | ||
return reason; | ||
} | ||
|
||
invalid_source_file_exceptiont::invalid_source_file_exceptiont( | ||
std::string reason) | ||
: reason(std::move(reason)) | ||
: cprover_exception_baset(std::move(reason)) | ||
{ | ||
} | ||
|
||
std::string invalid_source_file_exceptiont::what() const | ||
{ | ||
return reason; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this was removed from the inheritance chain? Would it be better if
message
was removed and substituted withreason
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this class,
message
is astd::ostringstream
, making it really different from the parent class. Really, there is no meaningful commonality.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only benefit would be to catch all these exceptions at once, which could be done by another 'base class with reason' above the existing base, but that's minor IMO.