#[non_exhaustive]pub struct JmapError {
pub error_type: String,
pub description: Option<String>,
pub existing_id: Option<Id>,
pub limit: Option<u64>,
}Expand description
JMAP method-level error, serializable for inclusion in methodResponses.
See RFC 8620 §3.6.2 for the standard error type strings.
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: StringError type string per RFC 8620 §3.6.2.
description: Option<String>Human-readable description. Omitted from JSON when None.
existing_id: Option<Id>The id of the existing record. Only set for "alreadyExists" (RFC 8620 §5.4 MUST).
limit: Option<u64>Maximum maxChanges value the server will accept. Only set for "tooManyChanges" (RFC 8620 §9.6.1 MUST).
Implementations§
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 request_too_large() -> JmapError
pub fn request_too_large() -> JmapError
RFC 8620 §5.1 and §5.3 — “requestTooLarge”
Sourcepub fn over_quota() -> JmapError
pub fn over_quota() -> JmapError
RFC 8620 §5.3 — “overQuota”
Sourcepub fn rate_limit() -> JmapError
pub fn rate_limit() -> JmapError
RFC 8620 §5.3 — “rateLimit”
Sourcepub fn invalid_patch() -> JmapError
pub fn invalid_patch() -> JmapError
RFC 8620 §5.3 — “invalidPatch”
Sourcepub fn will_destroy() -> JmapError
pub fn will_destroy() -> JmapError
RFC 8620 §5.3 — “willDestroy”
Sourcepub fn invalid_properties() -> JmapError
pub fn invalid_properties() -> JmapError
RFC 8620 §5.3 — “invalidProperties”
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 already_exists(existing_id: Id) -> JmapError
pub fn already_exists(existing_id: Id) -> JmapError
RFC 8620 §5.4 — “alreadyExists”
existing_id is the id of the record that already exists in the target account.
Per RFC 8620 §5.4, this field MUST be present on the SetError object.
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() -> JmapError
👎Deprecated: always use too_many_changes_with_limit to include the limit per RFC 8620 §9.6.1
pub fn too_many_changes() -> JmapError
always use too_many_changes_with_limit to include the limit per RFC 8620 §9.6.1
RFC 8620 §5.6 — “tooManyChanges”
Always prefer too_many_changes_with_limit,
which includes the server’s limit so the client knows the
maximum maxChanges value to use on retry. RFC 8620 §9.6.1
requires limit to be present on the wire; this bare constructor
produces a wire form that violates that requirement.
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").
The HTTP layer MUST forward this name as the "limit" property in the
RFC 7807 Problem Details response body. The name is stored in
description for that purpose.
Invariant: always construct limit errors with this function, never by
setting error_type = "limit" and description manually. The HTTP
response layer (jmap-server::RequestError) reads description to
populate the RFC-required "limit" field; a missing description produces
an invalid response.
Sourcepub fn unknown_capability() -> JmapError
👎Deprecated: always use unknown_capability_with_detail to include the URI in the error
pub fn unknown_capability() -> JmapError
always use unknown_capability_with_detail to include the URI in the error
RFC 8620 §3.6.1 — “unknownCapability” (request-level error)
The request used a capability URI not recognized by this server.
Always prefer unknown_capability_with_detail,
which includes the failing URI so clients can act on it.
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.
Always use this instead of unknown_capability().
The URI is stored in description. The HTTP layer
(jmap-server::RequestError) reads description to populate the "detail" field
in the RFC 7807 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.
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 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.