MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / parse_error

Class parse_error

native/thirdpart/json/json.hpp:1935–1982  ·  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

1933@since version 3.0.0
1934*/
1935class parse_error : public exception
1936{
1937 public:
1938 /*!
1939 @brief create a parse error exception
1940 @param[in] id_ the id of the exception
1941 @param[in] pos the position where the error occurred (or with
1942 chars_read_total=0 if the position cannot be
1943 determined)
1944 @param[in] what_arg the explanatory string
1945 @return parse_error object
1946 */
1947 static parse_error create(int id_, const position_t& pos, const std::string& what_arg)
1948 {
1949 std::string w = exception::name("parse_error", id_) + "parse error" +
1950 position_string(pos) + ": " + what_arg;
1951 return parse_error(id_, pos.chars_read_total, w.c_str());
1952 }
1953
1954 static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
1955 {
1956 std::string w = exception::name("parse_error", id_) + "parse error" +
1957 (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
1958 ": " + what_arg;
1959 return parse_error(id_, byte_, w.c_str());
1960 }
1961
1962 /*!
1963 @brief byte index of the parse error
1964
1965 The byte index of the last read character in the input file.
1966
1967 @note For an input with n bytes, 1 is the index of the first character and
1968 n+1 is the index of the terminating null byte or the end of file.
1969 This also holds true when reading a byte vector (CBOR or MessagePack).
1970 */
1971 const std::size_t byte;
1972
1973 private:
1974 parse_error(int id_, std::size_t byte_, const char* what_arg)
1975 : exception(id_, what_arg), byte(byte_) {}
1976
1977 static std::string position_string(const position_t& pos)
1978 {
1979 return " at line " + std::to_string(pos.lines_read + 1) +
1980 ", column " + std::to_string(pos.chars_read_current_line);
1981 }
1982};
1983
1984/*!
1985@brief exception indicating errors with iterators

Callers 1

createMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected