1#ifndef SOURCEMETA_CORE_JSONLD_ERROR_H_
2#define SOURCEMETA_CORE_JSONLD_ERROR_H_
4#ifndef SOURCEMETA_CORE_JSONLD_EXPORT
5#include <sourcemeta/core/jsonld_export.h>
8#include <sourcemeta/core/json.h>
9#include <sourcemeta/core/jsonpointer.h>
12#include <initializer_list>
15namespace sourcemeta::core {
21#pragma warning(disable : 4251 4275)
28class SOURCEMETA_CORE_JSONLD_EXPORT
JSONLDError :
public std::exception {
32 : code_{code}, pointer_{std::move(pointer)} {}
36 : code_{code}, pointer_{
to_pointer(pointer)} {}
41 const std::initializer_list<JSON::StringView> children)
43 for (
const auto child : children) {
48 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
49 return this->code_.c_str();
54 [[nodiscard]]
auto pointer() const noexcept -> const Pointer & {
55 return this->pointer_;
76 [[nodiscard]]
auto key() const noexcept -> const
JSON::String & {
85#pragma warning(default : 4251 4275)
std::basic_string< Char, CharTraits, Allocator< Char > > String
The string type used by the JSON document.
Definition json_value.h:52
JSONLDError(const char *code, Pointer pointer)
Locate the error at an owned pointer.
Definition jsonld_error.h:31
JSONLDFragmentError(const char *code, Pointer pointer, JSON::String key)
Locate the error at a fragment entry.
Definition jsonld_error.h:71
JSONLDError(const char *code, const WeakPointer &pointer, const std::initializer_list< JSON::StringView > children)
Definition jsonld_error.h:40
JSONLDError(const char *code, const WeakPointer &pointer)
Locate the error at a weak pointer, materialising an owned pointer.
Definition jsonld_error.h:35
auto key() const noexcept -> const JSON::String &
Definition jsonld_error.h:76
GenericPointer< JSON::String, PropertyHashJSON< JSON::String > > Pointer
Definition jsonpointer.h:39
SOURCEMETA_CORE_JSONPOINTER_EXPORT auto to_pointer(const JSON &document) -> Pointer
GenericPointer< std::reference_wrapper< const std::string >, PropertyHashJSON< JSON::String > > WeakPointer
Definition jsonpointer.h:44