MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / parse_error

Class parse_error

external/json/json.hpp:882–929  ·  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

880@since version 3.0.0
881*/
882class parse_error : public exception
883{
884 public:
885 /*!
886 @brief create a parse error exception
887 @param[in] id_ the id of the exception
888 @param[in] position the position where the error occurred (or with
889 chars_read_total=0 if the position cannot be
890 determined)
891 @param[in] what_arg the explanatory string
892 @return parse_error object
893 */
894 static parse_error create(int id_, const position_t& pos, const std::string& what_arg)
895 {
896 std::string w = exception::name("parse_error", id_) + "parse error" +
897 position_string(pos) + ": " + what_arg;
898 return parse_error(id_, pos.chars_read_total, w.c_str());
899 }
900
901 static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
902 {
903 std::string w = exception::name("parse_error", id_) + "parse error" +
904 (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
905 ": " + what_arg;
906 return parse_error(id_, byte_, w.c_str());
907 }
908
909 /*!
910 @brief byte index of the parse error
911
912 The byte index of the last read character in the input file.
913
914 @note For an input with n bytes, 1 is the index of the first character and
915 n+1 is the index of the terminating null byte or the end of file.
916 This also holds true when reading a byte vector (CBOR or MessagePack).
917 */
918 const std::size_t byte;
919
920 private:
921 parse_error(int id_, std::size_t byte_, const char* what_arg)
922 : exception(id_, what_arg), byte(byte_) {}
923
924 static std::string position_string(const position_t& pos)
925 {
926 return " at line " + std::to_string(pos.lines_read + 1) +
927 ", column " + std::to_string(pos.chars_read_current_line);
928 }
929};
930
931/*!
932@brief exception indicating errors with iterators

Callers 1

createMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected