#[non_exhaustive]pub struct JmapError {
pub error_type: MethodErrorType,
pub description: Option<String>,
pub limit: Option<u64>,
pub limit_name: Option<String>,
}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 7807 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).
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 too_large() -> Self
pub fn too_large() -> Self
“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() -> Self
pub fn request_too_large() -> Self
RFC 8620 §5.1 and §5.3 — “requestTooLarge”
Sourcepub fn rate_limit() -> Self
pub fn rate_limit() -> Self
“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() -> 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 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_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"),
stored in limit_name. The HTTP layer
(jmap-server::RequestError) writes it as the RFC-required "limit"
property of the RFC 7807 problem-details body.
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.
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.
Sourcepub fn custom(error_type: impl Into<MethodErrorType>) -> Self
pub fn custom(error_type: impl Into<MethodErrorType>) -> Self
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<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()