add a more specific example to explain how values are rejected and how atoi() fails

This commit is contained in:
Axel Kohlmeyer
2022-02-14 15:50:36 -05:00
parent 37cd4ba2ea
commit f84790ba62
3 changed files with 25 additions and 11 deletions

View File

@ -52,10 +52,15 @@ class Tokenizer {
std::vector<std::string> as_vector();
};
/** General Tokenizer exception class */
class TokenizerException : public std::exception {
std::string message;
public:
// remove unused default constructor
TokenizerException() = delete;
/** Thrown during retrieving or skipping tokens
*
* \param msg String with error message
@ -67,7 +72,10 @@ class TokenizerException : public std::exception {
const char *what() const noexcept override { return message.c_str(); }
};
/** Exception thrown by ValueTokenizer when trying to convert an invalid integer string */
class InvalidIntegerException : public TokenizerException {
public:
/** Thrown during converting string to integer number
*
@ -78,6 +86,8 @@ class InvalidIntegerException : public TokenizerException {
}
};
/** Exception thrown by ValueTokenizer when trying to convert an floating point string */
class InvalidFloatException : public TokenizerException {
public:
/** Thrown during converting string to floating point number