| 1 | #include "./parseerror.h" |
| 2 | |
| 3 | #include "../io/ansiescapecodes.h" |
| 4 | |
| 5 | #include <iostream> |
| 6 | |
| 7 | namespace CppUtilities { |
| 8 | |
| 9 | /*! |
| 10 | * \class ParseError |
| 11 | * \brief The ParseError class is thrown by an ArgumentParser when a parsing error occurs. |
| 12 | * \remarks The class might be used in other parsers, too. |
| 13 | * \sa ArgumentParser |
| 14 | */ |
| 15 | |
| 16 | /*! |
| 17 | * \brief Destroys the ParseError. |
| 18 | */ |
| 19 | ParseError::~ParseError() noexcept |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | /*! |
| 24 | * \brief Prints an error message "Unable to parse arguments: ..." for the specified \a failure. |
| 25 | */ |
| 26 | std::ostream &operator<<(std::ostream &o, const ParseError &failure) |
| 27 | { |
| 28 | using namespace std; |
| 29 | using namespace EscapeCodes; |
| 30 | return o << Phrases::Error << "Unable to parse arguments: " << TextAttribute::Reset << failure.what() << "\nSee --help for available commands." |
| 31 | << endl; |
| 32 | } |
| 33 | |
| 34 | } // namespace CppUtilities |