![]() |
OpenMS
|
Structured parse error with context for ProForma parsing. More...
#include <OpenMS/CHEMISTRY/ProFormaError.h>
Public Member Functions | |
| ProFormaParseError (const char *file, int line, const char *function, ProFormaErrorCode error_code, size_t error_position, const String &input, const String &message) noexcept | |
| Constructs a ProFormaParseError with full context information. | |
| ProFormaErrorCode | getErrorCode () const noexcept |
| Get the error code for programmatic handling. | |
| size_t | getPosition () const noexcept |
| Get byte position of error (0-indexed) | |
| const String & | getContextBefore () const noexcept |
| Get context before error (~20 chars) | |
| const String & | getContextAfter () const noexcept |
| Get context after error (~20 chars) | |
| const String & | getExpected () const noexcept |
| Get what was expected (if set) | |
| const String & | getFound () const noexcept |
| Get what was found (if set) | |
| String | getFormattedMessage () const |
| Get formatted error message with context visualization. | |
| void | setExpectedFound (const String &expected, const String &found) |
| Set expected/found information for more detailed error messages. | |
Public Member Functions inherited from ParseError | |
| ParseError (const char *file, int line, const char *function, const std::string &expression, const std::string &message) noexcept | |
Public Member Functions inherited from BaseException | |
| BaseException () noexcept | |
| Default constructor. | |
| BaseException (const char *file, int line, const char *function) noexcept | |
| Constructor. | |
| BaseException (const char *file, int line, const char *function, const std::string &name, const std::string &message) noexcept | |
| Constructor. | |
| BaseException (const BaseException &exception) noexcept | |
| Copy constructor. | |
| ~BaseException () noexcept override | |
| Destructor. | |
| const char * | getName () const noexcept |
| Returns the name of the exception. | |
| int | getLine () const noexcept |
| Returns the line number where it occurred. | |
| const char * | getFile () const noexcept |
| Returns the file where it occurred. | |
| const char * | getFunction () const noexcept |
| Returns the function where it occurred. | |
| const char * | getMessage () const noexcept |
| Returns the message. | |
Private Member Functions | |
| void | extractContext_ (const String &input, size_t pos) |
| Extract context snippets from input around the error position. | |
Private Attributes | |
| ProFormaErrorCode | code_ |
| Machine-readable error code. | |
| size_t | position_ |
| Position in input where error occurred. | |
| String | context_before_ |
| Text before the error position. | |
| String | context_after_ |
| Text after the error position. | |
| String | expected_ |
| What was expected (optional) | |
| String | found_ |
| What was found (optional) | |
Additional Inherited Members | |
Protected Attributes inherited from BaseException | |
| const char * | file_ |
| The source file the exception was thrown in. | |
| int | line_ |
| The line number the exception was thrown in. | |
| const char * | function_ |
| The source file the exception was thrown in. | |
| std::string | name_ |
| The name of the exception. | |
Structured parse error with context for ProForma parsing.
This exception extends Exception::ParseError to provide more detailed information about ProForma parsing failures, including:
Usage example:
|
noexcept |
Constructs a ProFormaParseError with full context information.
| [in] | file | Source file where the exception was thrown (use FILE). |
| [in] | line | Source line where the exception was thrown (use LINE). |
| [in] | function | Function name where the exception was thrown (use OPENMS_PRETTY_FUNCTION). |
| [in] | error_code | Machine-readable error code categorizing the error. |
| [in] | error_position | Byte position (0-indexed) in the input where the error occurred. Will be clamped to input.size() if out of bounds. |
| [in] | input | The complete input string that was being parsed. |
| [in] | message | Human-readable description of the error. |
|
private |
Extract context snippets from input around the error position.
Extracts approximately 20 characters before and after the error position for display in error messages. The position is assumed to be already clamped to input.size().
| [in] | input | The complete input string. |
| [in] | pos | The error position in the input (clamped to input.size()). |
|
inlinenoexcept |
Get context after error (~20 chars)
|
inlinenoexcept |
Get context before error (~20 chars)
|
inlinenoexcept |
Get the error code for programmatic handling.
|
inlinenoexcept |
Get what was expected (if set)
| String getFormattedMessage | ( | ) | const |
Get formatted error message with context visualization.
Returns a multi-line string formatted for human reading, showing:
|
inlinenoexcept |
Get what was found (if set)
|
inlinenoexcept |
Get byte position of error (0-indexed)
Set expected/found information for more detailed error messages.
| [in] | expected | Description of what was expected at the error position. |
| [in] | found | Description of what was actually found. |
|
private |
Machine-readable error code.
|
private |
Text after the error position.
|
private |
Text before the error position.
|
private |
What was expected (optional)
|
private |
What was found (optional)
|
private |
Position in input where error occurred.