Skip to main content

ServerError

Struct ServerError 

Source
pub struct ServerError { /* private fields */ }
Expand description

A transport-neutral server error. Display shows the public message only. Debug shows the log detail as Redacted and replaces the value of every crate::NEVER_LOG header with a placeholder; a sink that knows deployment-configured names logs headers through crate::Redactor instead.

Implementations§

Source§

impl ServerError

Source

pub fn new(code: Code, public: impl Into<Cow<'static, str>>) -> Self

An error with code and a client-safe public message.

Source

pub fn is_transport_admission_required(&self) -> bool

Whether a transport-identity (ssh or enc) pipeline refused because admission wants a payment or a reservation those transports cannot carry: the ssh binding answers “use mkit+https” for it, rather than a message that reads as a denied write.

Source

pub fn invalid_argument(public: impl Into<Cow<'static, str>>) -> Self

Source

pub fn unauthenticated(public: impl Into<Cow<'static, str>>) -> Self

Source

pub fn permission_denied(public: impl Into<Cow<'static, str>>) -> Self

Code::PermissionDenied, with its default HTTP status (403).

Source

pub fn admission_challenge(challenge: Bytes) -> Self

An admission challenge (SPEC-TRANSPORT-CONNECT §5.1): Code::PermissionDenied with HTTP status 402 and exactly one ADMISSION_CHALLENGE_TYPE detail. challenge is the encoded AdmissionChallenge message. Challenge headers such as WWW-Authenticate are added with Self::with_header.

Source

pub fn not_found(public: impl Into<Cow<'static, str>>) -> Self

Source

pub fn repository_not_found() -> Self

Code::NotFound for a repository that is missing or unreadable without revealing which (SPEC-WRITE-GRANTS §9.3).

Source

pub fn failed_precondition(public: impl Into<Cow<'static, str>>) -> Self

Source

pub fn resource_exhausted(public: impl Into<Cow<'static, str>>) -> Self

Code::ResourceExhausted: a client-attributable cap only (see Code).

Source

pub fn aborted_retryable(public: impl Into<Cow<'static, str>>) -> Self

Code::Aborted: the same operation is in flight and the client may retry it unchanged (PRD §5.4 stage 0, in_flight replay records).

Source

pub fn unavailable(public: impl Into<Cow<'static, str>>) -> Self

Source

pub fn unimplemented(public: impl Into<Cow<'static, str>>) -> Self

Source

pub fn internal(public: &'static str, detail: impl Display) -> Self

A backend failure: a fixed public message, with detail kept only for server-side logs (issue #794).

Source

pub fn with_http_status(self, status: u16) -> Self

Set the HTTP status the Connect binding answers with. Only error statuses (400..=599) are accepted, and 402 only on Code::PermissionDenied (use Self::admission_challenge). Any other value fails a debug assertion and is ignored.

Source

pub fn try_with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Result<Self, InvalidHeader>

Add a response header from dynamic input, e.g. a value an admission helper produced.

§Errors

InvalidHeader if the name is not an HTTP token, is reserved (a request credential, framing, hop-by-hop or cookie header), or the value holds a control character. self is dropped on error.

Source

pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Add a response header, e.g. WWW-Authenticate. An invalid or reserved header is dropped with a warning, so a credential or a framing header can never be echoed. A reserved name is a programming error and also fails a debug assertion; a malformed value never panics. Use Self::try_with_header to handle the failure instead.

Source

pub fn with_detail(self, detail: ErrorDetail) -> Self

Attach a typed error detail. An error carries at most one ADMISSION_CHALLENGE_TYPE detail (checked in debug builds).

Source

pub fn code(&self) -> Code

The error category.

Source

pub fn public_message(&self) -> &str

The client-safe message.

Source

pub fn log_detail(&self) -> Option<&str>

The server-side detail, for the log sink only.

Source

pub fn http_status(&self) -> Option<u16>

The HTTP status override, if any.

Source

pub fn headers(&self) -> &[(String, String)]

Response headers, in insertion order. Values may include receipts (crate::NEVER_LOG); log them through crate::Redactor.

Source

pub fn details(&self) -> &[ErrorDetail]

Typed error details, in insertion order.

Trait Implementations§

Source§

impl Clone for ServerError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ServerError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ServerError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<RefWireError> for ServerError

Source§

fn from(err: RefWireError) -> Self

The Connect code and message.

Source§

impl From<ServerError> for ConnectError

Source§

fn from(err: ServerError) -> Self

Converts to this type from the input type.
Source§

impl From<ServerError> for ResolveFailure

Source§

fn from(error: ServerError) -> Self

Converts to this type from the input type.
Source§

impl From<UploadError> for ServerError

Source§

fn from(err: UploadError) -> Self

The Connect code and message.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more