| 1 | #ifndef CONVERSION_UTILITIES_CONVERSIONEXCEPTION_H |
| 2 | #define CONVERSION_UTILITIES_CONVERSIONEXCEPTION_H |
| 3 | |
| 4 | #include "../global.h" |
| 5 | |
| 6 | #include <stdexcept> |
| 7 | #include <string> |
| 8 | |
| 9 | namespace CppUtilities { |
| 10 | |
| 11 | class CPP_UTILITIES_EXPORT ConversionException : public std::runtime_error { |
| 12 | public: |
| 13 | ConversionException() noexcept; |
| 14 | ConversionException(const std::string &what) noexcept; |
| 15 | ConversionException(const char *what) noexcept; |
| 16 | ~ConversionException() override; |
| 17 | }; |
| 18 | |
| 19 | /*! |
| 20 | * \class ConversionException |
| 21 | * \brief The ConversionException class is thrown by the various conversion |
| 22 | * functions of this library when a conversion error occurs. |
| 23 | */ |
| 24 | |
| 25 | /*! |
| 26 | * \brief Constructs a new ConversionException. |
| 27 | */ |
| 28 | inline ConversionException::ConversionException() noexcept |
| 29 | : runtime_error("unable to convert") |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | /*! |
| 34 | * \brief Constructs a new ConversionException. \a what is a std::string |
| 35 | * describing the cause of the ConversionException. |
| 36 | */ |
| 37 | inline ConversionException::ConversionException(const std::string &what) noexcept |
| 38 | : runtime_error(what) |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | /*! |
| 43 | * \brief Constructs a new ConversionException. \a what is a C-style string |
| 44 | * describing the cause of the ConversionException. |
| 45 | */ |
| 46 | inline ConversionException::ConversionException(const char *what) noexcept |
| 47 | : std::runtime_error(what) |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | } // namespace CppUtilities |
| 52 | |
| 53 | #endif // CONVERSION_UTILITIES_CONVERSIONEXCEPTION_H |