MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / parse_error

Class parse_error

3rd/json/include/nlohmann/json.hpp:214–261  ·  view source on GitHub ↗

! @brief exception indicating a parse error This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of JSON text, CBOR, MessagePack, as well as when using JSON Patch. Member @a byte holds the byte index of the last read character in the input file. Exceptions have ids 1xx. name / id | example message | descriptio

Source from the content-addressed store, hash-verified

212@since version 3.0.0
213*/
214class parse_error : public exception
215{
216 public:
217 /*!
218 @brief create a parse error exception
219 @param[in] id_ the id of the exception
220 @param[in] pos the position where the error occurred (or with
221 chars_read_total=0 if the position cannot be
222 determined)
223 @param[in] what_arg the explanatory string
224 @return parse_error object
225 */
226 static parse_error create(int id_, const position_t& pos, const std::string& what_arg)
227 {
228 std::string w = exception::name("parse_error", id_) + "parse error" +
229 position_string(pos) + ": " + what_arg;
230 return parse_error(id_, pos.chars_read_total, w.c_str());
231 }
232
233 static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
234 {
235 std::string w = exception::name("parse_error", id_) + "parse error" +
236 (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
237 ": " + what_arg;
238 return parse_error(id_, byte_, w.c_str());
239 }
240
241 /*!
242 @brief byte index of the parse error
243
244 The byte index of the last read character in the input file.
245
246 @note For an input with n bytes, 1 is the index of the first character and
247 n+1 is the index of the terminating null byte or the end of file.
248 This also holds true when reading a byte vector (CBOR or MessagePack).
249 */
250 const std::size_t byte;
251
252 private:
253 parse_error(int id_, std::size_t byte_, const char* what_arg)
254 : exception(id_, what_arg), byte(byte_) {}
255
256 static std::string position_string(const position_t& pos)
257 {
258 return " at line " + std::to_string(pos.lines_read + 1) +
259 ", column " + std::to_string(pos.chars_read_current_line);
260 }
261};
262
263/*!
264@brief exception indicating errors with iterators

Callers 1

createMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected