Skip to main content

Error

Enum Error 

Source
pub enum Error<E = Infallible> {
Show 24 variants InvalidContextNullification, LoadingDocumentFailed, ProcessingModeConflict, InvalidContextEntry, InvalidImportValue, InvalidRemoteContext, InvalidBaseIri, InvalidVocabMapping, CyclicIriMapping, InvalidTermDefinition, KeywordRedefinition, InvalidProtectedValue, InvalidTypeMapping, InvalidReverseProperty, InvalidIriMapping, InvalidKeywordAlias, InvalidContainerMapping, InvalidScopedContext, ProtectedTermRedefinition, ContextLoadingFailed(LoadError<E>), ContextExtractionFailed(ExtractContextError), RecursiveContextInclusion, ContextOverflow, ForbiddenVocab,
}
Expand description

Errors that can happen during context processing.

Variants§

§

InvalidContextNullification

A null context tried to clear an active context that holds protected term definitions, outside of a scope allowed to override them.

§

LoadingDocumentFailed

A remote @context IRI could not be resolved against the base URL.

Also used as a guard by the synchronous fast path, which refuses to continue if it meets a remote @context or an @import that the loader would have to fetch.

§

ProcessingModeConflict

A context declares @version while the processor is running in JSON-LD 1.0 mode.

§

InvalidContextEntry

A context entry is not permitted in the current processing mode.

Raised for @propagate, @import and @direction, all of which are JSON-LD 1.1 additions, and for an @imported context that itself contains @import.

§

InvalidImportValue

An @import value could not be resolved into an IRI against the base URL.

§

InvalidRemoteContext

An @imported document’s @context is not a single context definition object.

§

InvalidBaseIri

A @base value is neither an absolute IRI nor resolvable against the context’s current base IRI.

§

InvalidVocabMapping

A @vocab value did not expand to an IRI or blank node identifier.

Also raised in JSON-LD 1.0 mode for a document-relative @vocab, which only became legal in 1.1.

§

CyclicIriMapping

A term definition depends on itself, directly or through a chain of prefixes or @id values.

§

InvalidTermDefinition

A term definition is malformed or uses a JSON-LD 1.1 entry in 1.0 mode.

Raised for an empty term; for @protected, @context, @nest or @prefix under JSON-LD 1.0; for @index under JSON-LD 1.0 or without an @index container; for @prefix on a term containing : or /; for @prefix on a keyword alias; and for a stray @propagate inside a term definition.

§

KeywordRedefinition

A context tried to define a keyword as a term.

@type is the one exception, and only under JSON-LD 1.1, where it may be given @container: @set and @protected.

§

InvalidProtectedValue

An @protected entry holds something other than a boolean.

Rejected while parsing the context syntax, so context processing itself never raises this variant.

§

InvalidTypeMapping

A @type entry in a term definition does not name a usable type.

Raised when it expands to something that is not an IRI, @id, @vocab, @json or @none; when it is @json or @none under JSON-LD 1.0; and when a term with an @type container maps to a type other than @id or @vocab.

§

InvalidReverseProperty

An @reverse term definition is malformed.

Raised when it also carries @id or @nest, or when its @container is anything other than @set, @index or null.

§

InvalidIriMapping

A term could not be given an IRI mapping.

Raised when an @id or @reverse value does not expand to an IRI or blank node identifier, when a term that looks like a compact IRI or a path does not expand back to its own @id (JSON-LD 1.1 only), and when a term has no @id and cannot be resolved through a prefix or the vocabulary mapping.

§

InvalidKeywordAlias

A term definition tried to alias @context, which must never be aliasable.

§

InvalidContainerMapping

A @container value is not one of the permitted keywords or combinations, or uses @graph, @id, @type, an array or null under JSON-LD 1.0.

§

InvalidScopedContext

A @context inside a term definition failed to process.

The underlying error is deliberately replaced by this one, as the specification requires. The one exception is Self::ContextOverflow, which is passed through unchanged: a resource limit says nothing about the scoped context’s validity.

§

ProtectedTermRedefinition

A term marked @protected was redefined with a different meaning, outside of a scope allowed to override protected terms.

§

ContextLoadingFailed(LoadError<E>)

The Loader failed to fetch a document referenced by a remote @context or by @import.

§

ContextExtractionFailed(ExtractContextError)

A fetched document could not be reduced to a @context.

Raised when the document is not JSON-LD, or has no top-level object with a @context entry.

§

RecursiveContextInclusion

A remote context includes itself, directly or indirectly.

JSON-LD 1.0 only. Under 1.1 a context already on the remote-context stack is skipped while a scoped context is being validated and processed again everywhere else (context processing step 5.2.2), so only the Self::ContextOverflow limit constrains the chain.

§

ContextOverflow

A processor-defined resource limit on context nesting was exceeded.

Raised when the chain of remote contexts grows past MAX_REMOTE_CONTEXTS, which is the limit the context processing algorithm mandates against unbounded remote context chains, and also when the synchronous fast path reaches its recursion depth limit on a deeply nested inline @context.

§

ForbiddenVocab

A term had to be expanded through the vocabulary mapping while Options::vocab was set to Action::Reject.

Implementations§

Source§

impl<E> Error<E>

Source

pub fn code(&self) -> ErrorCode

Returns the JSON-LD error code this error is reported under.

Trait Implementations§

Source§

impl<E: Debug> Debug for Error<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E> Display for Error<E>
where LoadError<E>: Display,

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E> Error for Error<E>
where LoadError<E>: Error, Self: Debug + Display,

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<E> From<LoadError<E>> for Error<E>

Source§

fn from(source: LoadError<E>) -> Self

Converts to this type from the input type.
Source§

impl<E> From<RejectVocab> for Error<E>

Source§

fn from(_value: RejectVocab) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<E> Freeze for Error<E>
where LoadError<E>: Freeze,

§

impl<E> RefUnwindSafe for Error<E>

§

impl<E> Send for Error<E>
where LoadError<E>: Send,

§

impl<E> Sync for Error<E>
where LoadError<E>: Sync,

§

impl<E> Unpin for Error<E>
where LoadError<E>: Unpin,

§

impl<E> UnsafeUnpin for Error<E>

§

impl<E> UnwindSafe for Error<E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> BorrowUnordered for T

Source§

fn as_unordered(&self) -> &Unordered<T>

Views this value as an Unordered reference.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, C> FromWithContext<T, C> for T

Source§

fn from_with(value: T, _context: &C) -> T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U, C> IntoWithContext<U, C> for T
where U: FromWithContext<T, C>,

Source§

fn into_with(self, context: &C) -> U

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

Source§

type Error = !

Source§

fn try_from_with( value: U, context: &C, ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U, C> TryIntoWithContext<U, C> for T
where U: TryFromWithContext<T, C>,

Source§

type Error = <U as TryFromWithContext<T, C>>::Error

Source§

fn try_into_with( self, context: &C, ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

Source§

impl<T> WithContext for T
where T: ?Sized,

Source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

Source§

fn into_with<C>(self, context: C) -> Contextual<T, C>
where T: Sized,