From 830b8846d63fee5976cd12e066f4d482ab54e54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 31 May 2017 18:10:55 +0200 Subject: [PATCH] Added more constructor options for exceptions. --- include/anthem/Exception.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/include/anthem/Exception.h b/include/anthem/Exception.h index 51986c4..96902b8 100644 --- a/include/anthem/Exception.h +++ b/include/anthem/Exception.h @@ -19,11 +19,20 @@ namespace anthem class Exception: public std::exception { public: - Exception() = delete; - Exception(const Exception &other) = delete; - Exception &operator=(const Exception &other) = delete; - Exception(Exception &&other) = default; - Exception &operator=(Exception &&other) = default; + explicit Exception() + : Exception("unspecified parser error") + { + } + + explicit Exception(const char *message) + : Exception(static_cast(message)) + { + } + + explicit Exception(const std::string &message) + : m_message{message} + { + } explicit Exception(const Location &location) : Exception(location, "unspecified error") @@ -44,6 +53,11 @@ class Exception: public std::exception { } + Exception(const Exception &other) = delete; + Exception &operator=(const Exception &other) = delete; + Exception(Exception &&other) = default; + Exception &operator=(Exception &&other) = default; + ~Exception() noexcept = default; const char *what() const noexcept