OpenMS
Loading...
Searching...
No Matches
ProFormaError.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
13
14namespace OpenMS
15{
16
42
49 OPENMS_DLLAPI const char* proFormaErrorCodeToString(ProFormaErrorCode code);
50
77 class OPENMS_DLLAPI ProFormaParseError :
79 {
80 public:
94 const char* file,
95 int line,
96 const char* function,
97 ProFormaErrorCode error_code,
98 size_t error_position,
99 const String& input,
100 const String& message
101 ) noexcept;
102
105 {
106 return code_;
107 }
108
110 size_t getPosition() const noexcept
111 {
112 return position_;
113 }
114
116 const String& getContextBefore() const noexcept
117 {
118 return context_before_;
119 }
120
122 const String& getContextAfter() const noexcept
123 {
124 return context_after_;
125 }
126
128 const String& getExpected() const noexcept
129 {
130 return expected_;
131 }
132
134 const String& getFound() const noexcept
135 {
136 return found_;
137 }
138
150
157 void setExpectedFound(const String& expected, const String& found);
158
159 private:
161 size_t position_;
166
177 void extractContext_(const String& input, size_t pos);
178 };
179
180} // namespace OpenMS
subpage TOPP_TargetedFileConverter Converts targeted feature or consensus feature files subpage TOPP_FileInfo Shows basic information about the file
Definition TOPP.doxygen:44
Parse Error exception.
Definition Exception.h:593
Structured parse error with context for ProForma parsing.
Definition ProFormaError.h:79
String found_
What was found (optional)
Definition ProFormaError.h:165
ProFormaErrorCode getErrorCode() const noexcept
Get the error code for programmatic handling.
Definition ProFormaError.h:104
size_t position_
Position in input where error occurred.
Definition ProFormaError.h:161
const String & getExpected() const noexcept
Get what was expected (if set)
Definition ProFormaError.h:128
void extractContext_(const String &input, size_t pos)
Extract context snippets from input around the error position.
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 code_
Machine-readable error code.
Definition ProFormaError.h:160
const String & getContextBefore() const noexcept
Get context before error (~20 chars)
Definition ProFormaError.h:116
const String & getContextAfter() const noexcept
Get context after error (~20 chars)
Definition ProFormaError.h:122
size_t getPosition() const noexcept
Get byte position of error (0-indexed)
Definition ProFormaError.h:110
String context_before_
Text before the error position.
Definition ProFormaError.h:162
const String & getFound() const noexcept
Get what was found (if set)
Definition ProFormaError.h:134
String expected_
What was expected (optional)
Definition ProFormaError.h:164
void setExpectedFound(const String &expected, const String &found)
Set expected/found information for more detailed error messages.
String context_after_
Text after the error position.
Definition ProFormaError.h:163
String getFormattedMessage() const
Get formatted error message with context visualization.
A more convenient string class.
Definition String.h:34
ProFormaErrorCode
Error codes for programmatic handling of ProForma parse errors.
Definition ProFormaError.h:25
@ INVALID_AMINO_ACID
Invalid amino acid one-letter code.
@ INVALID_CV_ACCESSION
Invalid CV accession number format.
@ UNEXPECTED_CHARACTER
Unexpected character encountered during parsing.
@ UNMATCHED_BRACKET
Closing bracket without matching open bracket.
@ DANGLING_CROSSLINK_LABEL
Crosslink label without a matching partner.
@ UNEXPECTED_END_OF_INPUT
Unexpected end of input string.
@ INVALID_MASS_VALUE
Invalid mass value format or value.
@ INVALID_CV_PREFIX
Invalid controlled vocabulary prefix (e.g., not UNIMOD, MOD, etc.)
@ EMPTY_SEQUENCE
Empty sequence provided.
@ UNKNOWN_MONOSACCHARIDE
Unknown monosaccharide abbreviation.
@ INVALID_OCCURRENCE_SPECIFIER
Invalid occurrence specifier (e.g., ^2)
@ UNCLOSED_BRACKET
Opening bracket without matching close bracket.
@ INTERNAL_ERROR
Internal parser error (should not occur)
@ INVALID_CHARGE
Invalid charge state specification.
@ INVALID_FORMULA
Invalid chemical formula.
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
const char * proFormaErrorCodeToString(ProFormaErrorCode code)
Convert error code to human-readable string.