#[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>) -> Self
pub fn invalid_arguments(desc: impl Into<String>) -> Self
RFC 8620 §3.6.2 — “invalidArguments”
Sourcepub fn account_not_found() -> Self
pub fn account_not_found() -> Self
RFC 8620 §5.1 — “accountNotFound”
Sourcepub fn account_not_supported_by_method() -> Self
pub fn account_not_supported_by_method() -> Self
RFC 8620 §5.1 — “accountNotSupportedByMethod”
Sourcepub fn account_read_only() -> Self
pub fn account_read_only() -> Self
RFC 8620 §5.1 — “accountReadOnly”
RFC 8620 §3.6.2 — “serverUnavailable”
Sourcepub fn server_fail(desc: impl Into<String>) -> Self
pub fn server_fail(desc: impl Into<String>) -> Self
RFC 8620 §3.6.2 — “serverFail”
Sourcepub fn server_partial_fail() -> Self
pub fn server_partial_fail() -> Self
RFC 8620 §3.6.2 — “serverPartialFail”
Sourcepub fn unknown_method() -> Self
pub fn unknown_method() -> Self
RFC 8620 §3.6.2 — “unknownMethod”
Sourcepub fn invalid_result_reference() -> Self
pub fn invalid_result_reference() -> Self
RFC 8620 §3.6.2 — “invalidResultReference”
Sourcepub fn cannot_calculate_changes() -> Self
pub fn cannot_calculate_changes() -> Self
RFC 8620 §5.2 and §5.6 — “cannotCalculateChanges”
Sourcepub fn state_mismatch() -> Self
pub fn state_mismatch() -> Self
RFC 8620 §5.3 — “stateMismatch”
Sourcepub fn request_too_large() -> Self
pub fn request_too_large() -> Self
RFC 8620 §5.1 and §5.3 — “requestTooLarge”
Sourcepub fn over_quota() -> Self
pub fn over_quota() -> Self
RFC 8620 §5.3 — “overQuota”
Sourcepub fn rate_limit() -> Self
pub fn rate_limit() -> Self
RFC 8620 §5.3 — “rateLimit”
Sourcepub fn invalid_patch() -> Self
pub fn invalid_patch() -> Self
RFC 8620 §5.3 — “invalidPatch”
Sourcepub fn will_destroy() -> Self
pub fn will_destroy() -> Self
RFC 8620 §5.3 — “willDestroy”
Sourcepub fn invalid_properties() -> Self
pub fn invalid_properties() -> Self
RFC 8620 §5.3 — “invalidProperties”
Sourcepub fn unsupported_filter() -> Self
pub fn unsupported_filter() -> Self
RFC 8620 §5.5 — “unsupportedFilter”
Sourcepub fn anchor_not_found() -> Self
pub fn anchor_not_found() -> Self
RFC 8620 §5.5 — “anchorNotFound”
Sourcepub fn already_exists(existing_id: Id) -> Self
pub fn already_exists(existing_id: Id) -> Self
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() -> Self
pub fn from_account_not_found() -> Self
RFC 8620 §5.4 — “fromAccountNotFound”
Sourcepub fn from_account_not_supported_by_method() -> Self
pub fn from_account_not_supported_by_method() -> Self
RFC 8620 §5.4 — “fromAccountNotSupportedByMethod”
Sourcepub fn unsupported_sort() -> Self
pub fn unsupported_sort() -> Self
RFC 8620 §5.5 — “unsupportedSort”
Sourcepub fn too_many_changes() -> Self
👎Deprecated: always use too_many_changes_with_limit to include the limit per RFC 8620 §9.6.1
pub fn too_many_changes() -> Self
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) -> Self
pub fn too_many_changes_with_limit(limit: u64) -> Self
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() -> Self
pub fn not_json() -> Self
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() -> Self
pub fn not_request() -> Self
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>) -> Self
pub fn limit(limit_name: impl Into<String>) -> Self
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() -> Self
👎Deprecated: always use unknown_capability_with_detail to include the URI in the error
pub fn unknown_capability() -> Self
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>) -> Self
pub fn unknown_capability_with_detail(uri: impl Into<String>) -> Self
“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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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()