MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / exception

Class exception

lesson6-Segmentation/json.hpp:2352–2377  ·  view source on GitHub ↗

! @brief general exception of the @ref basic_json class This class is an extension of `std::exception` objects with a member @a id for exception ids. It is used as the base class for all exceptions thrown by the @ref basic_json class. This class can hence be used as "wildcard" to catch exceptions. Subclasses: - @ref parse_error for exceptions indicating a parse error - @ref invalid_iterator for

Source from the content-addressed store, hash-verified

2350@since version 3.0.0
2351*/
2352class exception : public std::exception
2353{
2354 public:
2355 /// returns the explanatory string
2356 JSON_HEDLEY_RETURNS_NON_NULL
2357 const char* what() const noexcept override
2358 {
2359 return m.what();
2360 }
2361
2362 /// the id of the exception
2363 const int id;
2364
2365 protected:
2366 JSON_HEDLEY_NON_NULL(3)
2367 exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
2368
2369 static std::string name(const std::string& ename, int id_)
2370 {
2371 return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
2372 }
2373
2374 private:
2375 /// an exception object as storage for error messages
2376 std::runtime_error m;
2377};
2378
2379/*!
2380@brief exception indicating a parse error

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected