Skip to content

Commit

Permalink
Remove Error::kPrefix_ static string
Browse files Browse the repository at this point in the history
The SCRAM specific identifier is redundant.
Boost exception reporting dynamically prints the exception type.

Issue #219
  • Loading branch information
rakhimov committed Oct 15, 2017
1 parent 43862a7 commit 7e8938b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@

namespace scram {

const char Error::kPrefix_[] = "scram error: ";

Error::Error(std::string msg)
: msg_(std::move(msg)),
thrown_(kPrefix_ + msg_) {}
Error::Error(std::string msg) : msg_(std::move(msg)) {}

const char* Error::what() const noexcept {
if (const char* const* msg = boost::get_error_info<error::what>(*this))
return *msg;
return thrown_.c_str();
return msg_.c_str();
}

} // namespace scram
7 changes: 1 addition & 6 deletions src/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,10 @@ class Error : virtual public std::exception, virtual public boost::exception {
/// Sets the error messages.
///
/// @param[in] msg The error message.
void msg(std::string msg) {
msg_ = std::move(msg);
thrown_ = kPrefix_ + msg_;
}
void msg(std::string msg) { msg_ = std::move(msg); }

private:
static const char kPrefix_[]; ///< Prefix specific to SCRAM.
std::string msg_; ///< The error message.
std::string thrown_; ///< The message to throw with the prefix.
};

/// For input/output related errors.
Expand Down

0 comments on commit 7e8938b

Please sign in to comment.