#[non_exhaustive]pub struct SetError {
pub error_type: SetErrorType,
pub description: Option<String>,
pub properties: Option<Vec<String>>,
pub existing_id: Option<Id>,
pub max_recipients: Option<u64>,
pub invalid_recipients: Option<Vec<String>>,
pub not_found: Option<Vec<Id>>,
pub max_size: Option<u64>,
pub extra: Map<String, Value>,
}Expand description
A per-item error in a /set response (notCreated, notUpdated,
notDestroyed maps) (RFC 8620 §5.3).
Construct with SetError::new and chain the builder methods as needed.
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: SetErrorTypeThe machine-readable error type.
description: Option<String>Optional human-readable description of the error.
properties: Option<Vec<String>>Property names that caused the error (for invalidProperties).
existing_id: Option<Id>The existing object id (for alreadyExists — RFC 8621 §5.7).
max_recipients: Option<u64>Maximum recipients allowed (for tooManyRecipients — RFC 8621 §7.5).
invalid_recipients: Option<Vec<String>>Invalid recipient addresses (for invalidRecipients — RFC 8621 §7.5).
not_found: Option<Vec<Id>>Missing blob IDs (for blobNotFound — RFC 8621 §5.5).
max_size: Option<u64>Maximum message size in octets (for tooLarge on EmailSubmission — RFC 8621 §7.5).
extra: Map<String, Value>Catch-all for extension-defined SetError fields not covered by the typed members above.
JMAP extensions sometimes ship error variants whose wire shape
includes additional structured fields beyond the RFC 8620 §5.3
base set — e.g. JMAP Chat’s rateLimited SetError carries a
serverRetryAfter UTCDate telling the client when it may
retry, and mdnAlreadySent (RFC 8621 §7.7) is a typed
extension error variant. This map preserves any such field
across serialize / deserialize round-trip, mirroring the
extras-preservation policy on the client-side
jmap_types::SetError type.
Use SetError::with_extra to populate from handler code:
SetError::new(SetErrorType::custom("rateLimited"))
.with_description("Slow mode is active for this chat")
.with_extra("serverRetryAfter", json!(retry_after_str))Per workspace AGENTS.md “Extras-preservation policy” — wire
format is byte-identical to a pre-extras SetError when the
map is empty (the skip_serializing_if collapses it).
Implementations§
Source§impl SetError
impl SetError
Sourcepub fn new(error_type: SetErrorType) -> Self
pub fn new(error_type: SetErrorType) -> Self
Construct a SetError with the given type and all optional fields None.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set the human-readable description.
Sourcepub fn with_properties<I, S>(self, props: I) -> Self
pub fn with_properties<I, S>(self, props: I) -> Self
Set the list of property names that caused the error.
Sourcepub fn with_existing_id(self, id: Id) -> Self
pub fn with_existing_id(self, id: Id) -> Self
Set the existing object id (used with alreadyExists).
Sourcepub fn with_max_recipients(self, n: u64) -> Self
pub fn with_max_recipients(self, n: u64) -> Self
Set the maximum recipients (used with tooManyRecipients — RFC 8621 §7.5).
Sourcepub fn with_invalid_recipients<I, S>(self, addrs: I) -> Self
pub fn with_invalid_recipients<I, S>(self, addrs: I) -> Self
Set the invalid recipient addresses (used with invalidRecipients — RFC 8621 §7.5).
Sourcepub fn with_not_found(self, ids: Vec<Id>) -> Self
pub fn with_not_found(self, ids: Vec<Id>) -> Self
Set the missing blob IDs (used with blobNotFound — RFC 8621 §5.5).
Sourcepub fn with_max_size(self, n: u64) -> Self
pub fn with_max_size(self, n: u64) -> Self
Set the maximum message size in octets (used with tooLarge on EmailSubmission — RFC 8621 §7.5).
Sourcepub fn with_extra(self, key: &str, value: Value) -> Self
pub fn with_extra(self, key: &str, value: Value) -> Self
Insert an extension-defined field into Self::extra.
Used by handlers to attach typed wire fields that no with_*
builder covers — for example JMAP Chat’s rateLimited SetError
must carry a serverRetryAfter UTCDate:
SetError::new(SetErrorType::custom("rateLimited"))
.with_description("Slow mode is active for this chat")
.with_extra("serverRetryAfter", serde_json::json!(retry_after_str))The serialized wire shape merges key/value at the same
level as the typed fields (via #[serde(flatten)] on
Self::extra). Calling with_extra("type", ...),
with_extra("properties", ...), or any other reserved
wire-name will produce a malformed SetError on the wire —
callers are responsible for choosing extension-namespace keys
that do not collide with the typed-field wire names.