|
JSON Voorhees
Killer JSON for C++
|
Exception thrown if there is any problem running serialize or to_json.
More...
#include <jsonv/serialization/serialization_error.hpp>
Inheritance diagram for jsonv::serialization_error:
Collaboration diagram for jsonv::serialization_error:Public Member Functions | |
| serialization_error (jsonv::path path, const std::type_info &type, std::string message, std::exception_ptr cause=nullptr) | |
| Create a new exception for a failure at path while serializing type, described by message and, if an exception caused it, carrying that exception as cause. | |
| serialization_error (jsonv::path path, const std::type_index &type, std::string message, std::exception_ptr cause=nullptr) | |
As above, naming the type by its std::type_index. | |
| const jsonv::path & | path () const noexcept |
| The path of the slot the failing serializer was writing into. | |
| std::type_index | type_index () const noexcept |
| Get an ID for the type which was being serialized. | |
| std::string_view | type_name () const noexcept |
| The demangled name of the type which was being serialized. | |
| const std::string & | message () const noexcept |
Human-readable details about what went wrong, without the position what prefixes them with. | |
| const std::exception_ptr & | nested_ptr () const noexcept |
The exception which caused this one, if there was one: what the serializer threw. | |
Exception thrown if there is any problem running serialize or to_json.
It says where the failure was found, as the path of the slot the failing serializer was writing into, and what was being serialized there, as the demangled type_name. Whatever the serializer threw is kept in nested_ptr, unless the failure was thrown as a serialization_error to begin with, as a no_serializer is.
The path is the writer::current_path of the writer the failing serializer was handed, so it names a position in the document being written. A serializer on the value bridge – a value_serializer_for, a value_adapter_for, a function returning a value, or a polymorphic_adapter subtype registered with keyed_subtype_action::check or keyed_subtype_action::insert – serializes its parts through a writer of its own, so a failure inside one of those reports a path from that tree's root rather than from the document's.
Definition at line 42 of file serialization_error.hpp.
|
noexcept |
The exception which caused this one, if there was one: what the serializer threw.
This is nullptr when the failure was thrown as a serialization_error in the first place.
|
noexcept |
The path of the slot the failing serializer was writing into.
This is empty for a failure at the root of the document, and for one which did not happen while writing, such as a no_serializer thrown by formats::get_serializer.