Mercurial > code
changeset 423:70f5cb449a22
Js: get rid of ExceptionAbstract
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 12 Oct 2015 21:57:38 +0200 |
parents | f32aaed52c93 |
children | 0dd7d9dd554a |
files | C++/modules/Js/Js.h |
diffstat | 1 files changed, 32 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/C++/modules/Js/Js.h Thu Oct 08 15:54:05 2015 +0200 +++ b/C++/modules/Js/Js.h Mon Oct 12 21:57:38 2015 +0200 @@ -976,32 +976,42 @@ * ------------------------------------------------------------------ */ /** - * @class ExceptionAbstract - * @brief Base class for standard ECMAScript exceptions. + * @class Error + * @brief Base ECMAScript error class. * @warning Override the function create for your own exceptions */ -class ExceptionAbstract { +class Error { protected: std::string m_name; //!< Name of exception (e.g RangeError) std::string m_message; //!< The message + /** + * Constructor with a type of error specified, specially designed for derived errors. + * + * @param message the message + */ + inline Error(std::string name, std::string message) noexcept + : m_name{std::move(name)} + , m_message{std::move(message)} + { + } + public: /** - * Construct an exception of type name with the specified message. + * Constructor with a message. * - * @param name the name (e.g TypeError) * @param message the message */ - inline ExceptionAbstract(std::string name, std::string message) noexcept - : m_name(std::move(name)) - , m_message(std::move(message)) + inline Error(std::string message) noexcept + : m_name{"Error"} + , m_message{std::move(message)} { } /** - * Get the exception type name. + * Get the error type (e.g RangeError). * - * @return the exception type + * @return the name */ inline const std::string &name() const noexcept { @@ -1023,33 +1033,16 @@ }; /** - * @class Error - * @brief Base ECMAScript error class. - */ -class Error : public ExceptionAbstract { -public: - /** - * Constructor with a message. - * - * @param message the message - */ - inline Error(std::string message) noexcept - : ExceptionAbstract{"Error", std::move(message)} - { - } -}; - -/** * @class EvalError * @brief Error in eval() function. */ -class EvalError : public ExceptionAbstract { +class EvalError : public Error { public: /** * @copydoc Error */ inline EvalError(std::string message) noexcept - : ExceptionAbstract{"EvalError", std::move(message)} + : Error{"EvalError", std::move(message)} { } }; @@ -1058,13 +1051,13 @@ * @class RangeError * @brief Value is out of range. */ -class RangeError : public ExceptionAbstract { +class RangeError : public Error { public: /** * @copydoc Error */ inline RangeError(std::string message) noexcept - : ExceptionAbstract{"RangeError", std::move(message)} + : Error{"RangeError", std::move(message)} { } }; @@ -1073,13 +1066,13 @@ * @class ReferenceError * @brief Trying to use a variable that does not exist. */ -class ReferenceError : public ExceptionAbstract { +class ReferenceError : public Error { public: /** * @copydoc Error */ inline ReferenceError(std::string message) noexcept - : ExceptionAbstract{"ReferenceError", std::move(message)} + : Error{"ReferenceError", std::move(message)} { } }; @@ -1088,13 +1081,13 @@ * @class SyntaxError * @brief Syntax error in the script. */ -class SyntaxError : public ExceptionAbstract { +class SyntaxError : public Error { public: /** * @copydoc Error */ inline SyntaxError(std::string message) noexcept - : ExceptionAbstract{"SyntaxError", std::move(message)} + : Error{"SyntaxError", std::move(message)} { } }; @@ -1103,13 +1096,13 @@ * @class TypeError * @brief Invalid type given. */ -class TypeError : public ExceptionAbstract { +class TypeError : public Error { public: /** * @copydoc Error */ inline TypeError(std::string message) noexcept - : ExceptionAbstract{"TypeError", std::move(message)} + : Error{"TypeError", std::move(message)} { } }; @@ -1118,13 +1111,13 @@ * @class URIError * @brief URI manipulation failure. */ -class URIError : public ExceptionAbstract { +class URIError : public Error { public: /** * @copydoc Error */ inline URIError(std::string message) noexcept - : ExceptionAbstract{"URIError", std::move(message)} + : Error{"URIError", std::move(message)} { } };