pub struct ErrorBody {
pub code: ErrorCode,
pub message: String,
pub extras: Box<ErrorExtras>,
}Expand description
An error object: code, message, and the code’s extra fields placed next to code
(§7.2, §11). Build it with the constructors (one per ErrorCode, see errors.rs); they
use fixed messages so no secret, connection detail, member key or other member’s data can
reach the wire (§11). The extras are boxed to keep Result<_, ErrorBody> small.
Fields§
§code: ErrorCodeWhat went wrong; clients branch on this only.
message: StringHuman-readable English text; informative, never branched on.
extras: Box<ErrorExtras>The code’s extra fields, serialised next to code (absent ones are omitted).
Implementations§
Source§impl ErrorBody
impl ErrorBody
Sourcepub fn bad_request(field: Option<&str>) -> Self
pub fn bad_request(field: Option<&str>) -> Self
BAD_REQUEST, naming the offending field path when known ("body.content"). The
path names a schema field; never put a received value in it.
Sourcepub fn payload_too_large(limit: u64) -> Self
pub fn payload_too_large(limit: u64) -> Self
PAYLOAD_TOO_LARGE with the limit exceeded, in bytes or items.
Sourcepub fn unsupported_version(supported: VersionRange) -> Self
pub fn unsupported_version(supported: VersionRange) -> Self
UNSUPPORTED_VERSION with the host’s supported range.
Sourcepub fn unsupported_feature(feature: impl Into<Cow<'static, str>>) -> Self
pub fn unsupported_feature(feature: impl Into<Cow<'static, str>>) -> Self
UNSUPPORTED_FEATURE naming the feature ("attachments", "voice", a reserved
command name). The name may be dynamic (BodyError::UnsupportedFeature) but must be a
protocol name, never text taken from a secret or another member (§11).
Sourcepub fn forbidden(missing: Option<u64>, reason: Option<Reason>) -> Self
pub fn forbidden(missing: Option<u64>, reason: Option<Reason>) -> Self
FORBIDDEN, with the missing permission bits and the cause when known.
Sourcepub fn suspended(until: Option<u64>) -> Self
pub fn suspended(until: Option<u64>) -> Self
SUSPENDED, with the end of the suspension when it has one.
Sourcepub fn invalid_signature(object: &'static str) -> Self
pub fn invalid_signature(object: &'static str) -> Self
INVALID_SIGNATURE naming the signed object ("descriptor", "delegation", …).
Sourcepub fn slowmode_active(retry_after_ms: u64) -> Self
pub fn slowmode_active(retry_after_ms: u64) -> Self
SLOWMODE_ACTIVE (message as in the §7.2 example).
Sourcepub fn rate_limited(
retry_after_ms: u64,
scope: RateScope,
category: Option<RateCategory>,
) -> Self
pub fn rate_limited( retry_after_ms: u64, scope: RateScope, category: Option<RateCategory>, ) -> Self
RATE_LIMITED with the scope and, when one applies, the category.
Sourcepub fn resync_required_member() -> Self
pub fn resync_required_member() -> Self
RESYNC_REQUIRED for the member stream.
Sourcepub fn resync_required_channel(channel_id: ChannelId) -> Self
pub fn resync_required_channel(channel_id: ChannelId) -> Self
RESYNC_REQUIRED for a channel stream.
Source§impl ErrorBody
impl ErrorBody
Sourcepub fn with_message(self, message: &'static str) -> Self
pub fn with_message(self, message: &'static str) -> Self
Replaces the default message with another fixed one.
Sourcepub const fn is_recorded(&self) -> bool
pub const fn is_recorded(&self) -> bool
Whether a response carrying this error is stored as the idempotency record (§7.3).
Sourcepub fn unsupported_command() -> Self
pub fn unsupported_command() -> Self
UNSUPPORTED_COMMAND: unknown type.
Sourcepub fn hello_required() -> Self
pub fn hello_required() -> Self
HELLO_REQUIRED: a command before a successful session.hello.
Sourcepub fn wrong_community() -> Self
pub fn wrong_community() -> Self
WRONG_COMMUNITY: community_id differs from the binding.
HOST_NOT_AUTHORIZED: no valid delegation for the community.
Sourcepub fn pending_approval() -> Self
pub fn pending_approval() -> Self
PENDING_APPROVAL: the member is pending.
Sourcepub fn admission_closed() -> Self
pub fn admission_closed() -> Self
ADMISSION_CLOSED (one code for every cause, so it is not an oracle).
Sourcepub fn invite_invalid() -> Self
pub fn invite_invalid() -> Self
INVITE_INVALID (one code for every cause, so it is not an oracle).