#[non_exhaustive]pub struct JmapError {
pub error_type: MethodErrorType,
pub description: Option<String>,
pub limit: Option<u64>,
pub limit_name: Option<String>,
pub extra: Map<String, Value>,
}Expand description
JMAP method-level error, serializable for inclusion in methodResponses.
See RFC 8620 §3.6.2 for the standard error types.
The JSON key is "type" (not "error_type") per RFC 8620.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.error_type: MethodErrorTypeError type per RFC 8620 §3.6.
description: Option<String>Human-readable description. Omitted from JSON when None.
limit: Option<u64>Maximum maxChanges value the server will accept. Only set for "tooManyChanges" (RFC 8620 §9.6.1 MUST).
limit_name: Option<String>Name of the exceeded limit for a request-level limit error
(RFC 8620 §3.6.1: “the “limit” property MUST contain the name of
the limit being applied“), e.g. "maxCallsInRequest".
Request-level errors are sent as an RFC 9457 problem-details body,
where jmap-server writes this as the "limit" property. It never
appears in a methodResponses error, so it is not serialized here
(the limit key there is the tooManyChanges count).
extra: Map<String, Value>Other properties of the error object (RFC 8620 §3.6.2: “Other
properties may be present”), such as draft-ietf-jmap-conditional-02
§3.3 failed and the §4.2 atomicFailure maps. Kept on decode
and written flat beside type.
Implementations§
Source§impl JmapError
impl JmapError
Sourcepub fn state_mismatch_failed(failed: Vec<Id>) -> JmapError
pub fn state_mismatch_failed(failed: Vec<Id>) -> JmapError
A stateMismatch error for failed ifUnchangedBy preconditions,
naming the objects (§3.3 failed: “The ids of the objects whose
preconditions were not satisfied”).
Sourcepub fn atomic_failure(details: AtomicFailure) -> JmapError
pub fn atomic_failure(details: AtomicFailure) -> JmapError
An atomicFailure error (§4.2) carrying details’ maps as
properties of the error object.
Sourcepub fn cannot_apply_atomically() -> JmapError
pub fn cannot_apply_atomically() -> JmapError
A cannotApplyAtomically error (§4.3).
Sourcepub fn failed(&self) -> Option<Vec<Id>>
pub fn failed(&self) -> Option<Vec<Id>>
The §3.3 failed ids of a stateMismatch error, or None when
this is another error or failed is absent or malformed.
Sourcepub fn atomic_failure_details(&self) -> Option<AtomicFailure>
pub fn atomic_failure_details(&self) -> Option<AtomicFailure>
The §4.2 details of an atomicFailure error, or None when this is
another error or the maps are malformed.
Source§impl JmapError
impl JmapError
Sourcepub fn invalid_arguments(desc: impl Into<String>) -> JmapError
pub fn invalid_arguments(desc: impl Into<String>) -> JmapError
RFC 8620 §3.6.2 — “invalidArguments”
Sourcepub fn account_not_found() -> JmapError
pub fn account_not_found() -> JmapError
RFC 8620 §5.1 — “accountNotFound”
Sourcepub fn account_not_supported_by_method() -> JmapError
pub fn account_not_supported_by_method() -> JmapError
RFC 8620 §5.1 — “accountNotSupportedByMethod”
Sourcepub fn account_read_only() -> JmapError
pub fn account_read_only() -> JmapError
RFC 8620 §5.1 — “accountReadOnly”
RFC 8620 §3.6.2 — “serverUnavailable”
Sourcepub fn server_fail(desc: impl Into<String>) -> JmapError
pub fn server_fail(desc: impl Into<String>) -> JmapError
RFC 8620 §3.6.2 — “serverFail”
Sourcepub fn server_partial_fail() -> JmapError
pub fn server_partial_fail() -> JmapError
RFC 8620 §3.6.2 — “serverPartialFail”
Sourcepub fn unknown_method() -> JmapError
pub fn unknown_method() -> JmapError
RFC 8620 §3.6.2 — “unknownMethod”
Sourcepub fn invalid_result_reference() -> JmapError
pub fn invalid_result_reference() -> JmapError
RFC 8620 §3.6.2 — “invalidResultReference”
Sourcepub fn cannot_calculate_changes() -> JmapError
pub fn cannot_calculate_changes() -> JmapError
RFC 8620 §5.2 and §5.6 — “cannotCalculateChanges”
Sourcepub fn state_mismatch() -> JmapError
pub fn state_mismatch() -> JmapError
RFC 8620 §5.3 — “stateMismatch”
Sourcepub fn too_large() -> JmapError
pub fn too_large() -> JmapError
“tooLarge” — a method-level error of Principal/getAvailability
(draft-ietf-jmap-calendars §2.2); RFC 8620 §5.3 defines it only as
a SetError.
Sourcepub fn request_too_large() -> JmapError
pub fn request_too_large() -> JmapError
RFC 8620 §5.1 and §5.3 — “requestTooLarge”
Sourcepub fn rate_limit() -> JmapError
pub fn rate_limit() -> JmapError
“rateLimit” — a method-level error of Principal/getAvailability
(draft-ietf-jmap-calendars §2.2); RFC 8620 §5.3 defines it only as
a SetError.
Sourcepub fn unsupported_filter() -> JmapError
pub fn unsupported_filter() -> JmapError
RFC 8620 §5.5 — “unsupportedFilter”
Sourcepub fn anchor_not_found() -> JmapError
pub fn anchor_not_found() -> JmapError
RFC 8620 §5.5 — “anchorNotFound”
Sourcepub fn from_account_not_found() -> JmapError
pub fn from_account_not_found() -> JmapError
RFC 8620 §5.4 — “fromAccountNotFound”
Sourcepub fn from_account_not_supported_by_method() -> JmapError
pub fn from_account_not_supported_by_method() -> JmapError
RFC 8620 §5.4 — “fromAccountNotSupportedByMethod”
Sourcepub fn unsupported_sort() -> JmapError
pub fn unsupported_sort() -> JmapError
RFC 8620 §5.5 — “unsupportedSort”
Sourcepub fn too_many_changes_with_limit(limit: u64) -> JmapError
pub fn too_many_changes_with_limit(limit: u64) -> JmapError
Returns a tooManyChanges error with the server’s limit included.
Per RFC 8620 §9.6.1, the limit field MUST be present so the client
knows the maximum maxChanges value to use on retry.
Sourcepub fn not_json() -> JmapError
pub fn not_json() -> JmapError
RFC 8620 §3.6.1 — “notJSON” (request-level error)
The request body was not valid JSON or did not have application/json content type.
Sourcepub fn not_request() -> JmapError
pub fn not_request() -> JmapError
RFC 8620 §3.6.1 — “notRequest” (request-level error)
The request parsed as JSON but did not match the JMAP Request object shape.
Sourcepub fn limit(limit_name: impl Into<String>) -> JmapError
pub fn limit(limit_name: impl Into<String>) -> JmapError
RFC 8620 §3.6.1 — “limit” (request-level error)
The request was rejected because it would exceed a capability limit such as
maxCallsInRequest or maxSizeRequest.
limit_name is the name of the exceeded limit (e.g. "maxCallsInRequest"),
stored in limit_name. The HTTP layer
(jmap-server::RequestError) writes it as the RFC-required "limit"
property of the RFC 9457 problem-details body.
Sourcepub fn unknown_capability_with_detail(uri: impl Into<String>) -> JmapError
pub fn unknown_capability_with_detail(uri: impl Into<String>) -> JmapError
“unknownCapability” with the failing URI surfaced to the client.
The URI is stored in description. The HTTP layer
(jmap-server::RequestError) reads description to populate the "detail" field
in the RFC 9457 problem-details response body — the same mechanism used by
limit() for its limit-name payload.
Invariant: always construct unknownCapability errors that carry a URI with this
function, never by setting description manually. A missing or incorrect description
means the client never learns which capability it requested that the server does not
support.
Sourcepub fn custom(error_type: impl Into<MethodErrorType>) -> JmapError
pub fn custom(error_type: impl Into<MethodErrorType>) -> JmapError
Create a JmapError with an extension error type such as
"rateLimited".
A string naming a known type builds that variant
(JmapError::custom("forbidden") equals JmapError::forbidden).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JmapError
impl<'de> Deserialize<'de> for JmapError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<JmapError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<JmapError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for JmapError
Source§impl Error for JmapError
impl Error for JmapError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<E: Error> From<BackendChangesError<E>> for JmapError
impl<E: Error> From<BackendChangesError<E>> for JmapError
Source§fn from(e: BackendChangesError<E>) -> Self
fn from(e: BackendChangesError<E>) -> Self
Source§impl<E> From<BackendQueryError<E>> for JmapError
impl<E> From<BackendQueryError<E>> for JmapError
Source§fn from(e: BackendQueryError<E>) -> Self
fn from(e: BackendQueryError<E>) -> Self
Source§impl From<JmapError> for RequestError
impl From<JmapError> for RequestError
Source§fn from(err: JmapError) -> Self
fn from(err: JmapError) -> Self
Convert a JmapError into a RequestError, deriving the HTTP
status code automatically via error_status.
Enables ? propagation in functions returning Result<_, RequestError>.
Pass only request-level errors; see error_status for the safe list.
Source§impl Serialize for JmapError
impl Serialize for JmapError
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for JmapError
Auto Trait Implementations§
impl Forget for JmapError
impl Freeze for JmapError
impl Move for JmapError
impl RefUnwindSafe for JmapError
impl Send for JmapError
impl Sync for JmapError
impl Unpin for JmapError
impl UnsafeUnpin for JmapError
impl UnwindSafe for JmapError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.