#[non_exhaustive]pub struct SetError {
pub error_type: String,
pub description: Option<String>,
pub properties: Option<Vec<String>>,
pub existing_id: Option<Id>,
pub not_found: Option<Vec<Id>>,
pub max_recipients: Option<u64>,
pub invalid_recipients: Option<Vec<String>>,
pub max_size: Option<u64>,
pub extra: Map<String, Value>,
}Expand description
A per-item failure in a /set response (RFC 8620 §5.3).
Appears as the value type in the notCreated, notUpdated, and
notDestroyed maps of SetResponse. The error_type field uses
String rather than a typed enum so extension errors (e.g.
"calendarHasEvent", "noSupportedScheduleMethods") round-trip
cleanly without requiring a version-bump on every new spec extension.
All fields beyond error_type are optional and present only when the
corresponding error type calls for them per RFC 8620 §5.3 / RFC 8621
§5.5, §5.7, §7.5:
| Field | Set when error_type is | Spec |
|---|---|---|
description | any (optional human-readable detail) | RFC 8620 §5.3 |
properties | invalidProperties | RFC 8620 §5.3 |
existing_id | alreadyExists | RFC 8620 §5.4, RFC 8621 §5.7 |
not_found | blobNotFound | RFC 8621 §5.5 |
max_recipients | tooManyRecipients | RFC 8621 §7.5 |
invalid_recipients | invalidRecipients | RFC 8621 §7.5 |
max_size | tooLarge | RFC 8621 §7.5 |
§Extension fields
JMAP extensions (e.g. JMAP Chat’s serverRetryAfter for slow-mode
rate limiting) MAY add additional SetError fields beyond the RFC 8620
base set. The extra field captures any such field via
#[serde(flatten)] so it round-trips losslessly. Extension crates
(e.g. jmap-chat-client) provide typed accessor helpers that read
from extra — the base type stays free of extension-specific fields.
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: StringThe machine-readable error type (e.g. "forbidden", "notFound",
"alreadyExists", or an extension-defined string).
description: Option<String>Human-readable description of the error. Optional per RFC 8620 §5.3.
properties: Option<Vec<String>>Property names that caused the error (for invalidProperties).
existing_id: Option<Id>The existing object id (for alreadyExists).
not_found: Option<Vec<Id>>Missing blob ids (for blobNotFound).
max_recipients: Option<u64>Maximum recipients allowed (for tooManyRecipients).
invalid_recipients: Option<Vec<String>>Invalid recipient addresses (for invalidRecipients).
max_size: Option<u64>Maximum message size in octets (for tooLarge).
extra: Map<String, Value>Catch-all for extension SetError fields not in the RFC 8620 base
set. Captured via #[serde(flatten)] so they round-trip losslessly.
Extension crates provide typed accessors (e.g.
jmap-chat-client’s helper for reading serverRetryAfter).
Uses serde_json::Map (which preserves insertion order) rather than
HashMap to match the workspace extras-preservation policy (see
workspace AGENTS.md) and to give callers deterministic serialized
output.
Implementations§
Source§impl SetError
impl SetError
Sourcepub fn new(error_type: impl Into<String>) -> Self
pub fn new(error_type: impl Into<String>) -> Self
Construct a SetError with the given type string and all optional
fields None / empty. Use this when deserializing tests or when
constructing a wire-shaped error from a typed source. Server crates
that want a typed enum for construction should use
jmap_server::backend::SetError (declared in the jmap-server
crate, not linkable from here since jmap-types does not depend on
jmap-server) — this type is deliberately String-typed for
client-side parsing flexibility.