Skip to content

Commit

Permalink
Remove error::what tag
Browse files Browse the repository at this point in the history
This tag has been a redundant way to specify the exception message.
The removal simplifies the Error class.
error.cc has become empty and unnecessary as well after this change.

Issue #219
  • Loading branch information
rakhimov committed Oct 15, 2017
1 parent 7e8938b commit c711dda
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 49 deletions.
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ endif()
set(SCRAM_CORE_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/env.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/version.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/error.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/logger.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/random.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/settings.cc"
Expand Down
35 changes: 0 additions & 35 deletions src/error.cc

This file was deleted.

15 changes: 2 additions & 13 deletions src/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,21 @@

namespace scram {

namespace error {

/// 'what' identifier for errors deriving from std::exception.
///
/// @note This should not be the error message to be printed for users.
/// It is the optional *identifier* string.
/// By default, boost::diagnostic_information_what is used.
using what = boost::error_info<struct tag_what, const char*>;

} // namespace error

/// The Error class is the base class
/// for common exceptions specific to the SCRAM code.
class Error : virtual public std::exception, virtual public boost::exception {
public:
/// Constructs a new error with a provided message.
///
/// @param[in] msg The message to be passed with this error.
explicit Error(std::string msg);
explicit Error(std::string msg) : msg_(std::move(msg)) {}

Error(const Error&) = default; ///< Explicit declaration.

virtual ~Error() noexcept = default;

/// @returns The formatted error message to be printed.
const char* what() const noexcept override;
const char* what() const noexcept final { return msg_.c_str(); }

/// @returns The core message describing the error.
const std::string& msg() const { return msg_; }
Expand Down

0 comments on commit c711dda

Please sign in to comment.