Commit 92662ff0389277a86ae86b2ff877c5a70c59169d
1 parent
b38a882a
add invalid_argument() exception
Showing
2 changed files
with
29 additions
and
0 deletions
include/GException.hpp
| @@ -60,6 +60,13 @@ public: | @@ -60,6 +60,13 @@ public: | ||
| 60 | std::string message = ""); | 60 | std::string message = ""); |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | + // Invalid argument | ||
| 64 | + class invalid_argument : public GExceptionHandler { | ||
| 65 | + public: | ||
| 66 | + invalid_argument(std::string origin, | ||
| 67 | + std::string message = ""); | ||
| 68 | + }; | ||
| 69 | + | ||
| 63 | // Bad type | 70 | // Bad type |
| 64 | class bad_type : public GExceptionHandler { | 71 | class bad_type : public GExceptionHandler { |
| 65 | public: | 72 | public: |
src/support/GException.cpp
| @@ -55,6 +55,28 @@ GException::feature_not_implemented::feature_not_implemented(std::string origin, | @@ -55,6 +55,28 @@ GException::feature_not_implemented::feature_not_implemented(std::string origin, | ||
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | /***********************************************************************//** | 57 | /***********************************************************************//** |
| 58 | + * @brief Invalid argument | ||
| 59 | + * | ||
| 60 | + * @param[in] origin Name of method that has thrown the exception. | ||
| 61 | + * @param[in] message Optional message. | ||
| 62 | + ***************************************************************************/ | ||
| 63 | +GException::invalid_argument::invalid_argument(std::string origin, | ||
| 64 | + std::string message) | ||
| 65 | +{ | ||
| 66 | + // Set origin | ||
| 67 | + m_origin = origin; | ||
| 68 | + | ||
| 69 | + // Set message string | ||
| 70 | + m_message = "Invalid argument encountered."; | ||
| 71 | + if (message.length() > 0) | ||
| 72 | + m_message += " " + message; | ||
| 73 | + | ||
| 74 | + // Return | ||
| 75 | + return; | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | + | ||
| 79 | +/***********************************************************************//** | ||
| 58 | * @brief Bad type | 80 | * @brief Bad type |
| 59 | * | 81 | * |
| 60 | * @param[in] origin Name of method that has thrown the exception. | 82 | * @param[in] origin Name of method that has thrown the exception. |