Skip to main content

LeashError

Enum LeashError 

Source
pub enum LeashError {
    PlanBlock {
        code: String,
        message: String,
        required_plan: Option<String>,
    },
    ConnectionRequired {
        provider: String,
        message: String,
        connect_url: Option<String>,
    },
    UpgradeRequired {
        message: String,
    },
    KeyNotDeclared {
        key: String,
    },
    Unauthorized {
        message: String,
    },
    Network(Error),
    UpstreamError {
        status: u16,
        message: String,
    },
    MalformedResponse {
        message: String,
    },
}
Expand description

The structured error returned by every Leash SDK call.

Variants are organised so the common branches (plan blocks, connection required, upgrades) have first-class shape — no string parsing needed. For everything else, LeashError::UpstreamError preserves the HTTP status and message; LeashError::MalformedResponse covers parse failures.

Variants§

§

PlanBlock

HTTP 402 — the caller’s plan does not include this feature.

The required_plan is best-effort: present when the platform reports it in the response body, absent otherwise.

Fields

§code: String

Stable code (UPGRADE_REQUIRED from the platform).

§message: String

Human-readable message.

§required_plan: Option<String>

The plan tier required to unlock this call, if reported.

§

ConnectionRequired

HTTP 403 — the user hasn’t connected this integration yet.

Fields

§provider: String

Provider id (e.g. gmail, linear).

§message: String

Human-readable message.

§connect_url: Option<String>

URL the caller can use to start the OAuth flow, when supplied.

§

UpgradeRequired

HTTP 402 surfaced from env.get — Growth plan or above is required.

Fields

§message: String

Human-readable message.

§

KeyNotDeclared

env.get was called for a key that isn’t declared in .env.example or doesn’t exist in any source.

Note: crate::Env::get returns Ok(None) for this case so callers can branch with if value.is_none(). This variant only fires when callers reach for the lower-level surface and want the explicit error.

Fields

§key: String

The env-var name that wasn’t recognised.

§

Unauthorized

HTTP 401 — missing or invalid credential.

Fields

§message: String

Human-readable message.

§

Network(Error)

Failure below the HTTP layer (DNS, refused connection, TLS, etc.).

§

UpstreamError

An upstream HTTP error that doesn’t map onto a more specific variant.

Fields

§status: u16

HTTP status code from the platform.

§message: String

Human-readable message (often pulled from the response body).

§

MalformedResponse

Platform returned a response we couldn’t deserialise.

Fields

§message: String

Diagnostic message including the field or shape that failed.

Implementations§

Source§

impl LeashError

Source

pub fn is_plan_block(&self) -> bool

True for LeashError::PlanBlock and LeashError::UpgradeRequired.

Use this to render a single “upgrade your plan” UI without caring which surface (integration POST vs env.get) tripped the block.

Source

pub fn is_upgrade_required(&self) -> bool

Alias of Self::is_plan_block matching the TS / Go naming.

Source

pub fn is_connection_required(&self) -> bool

Source

pub fn is_unauthorized(&self) -> bool

Source

pub fn is_key_not_declared(&self) -> bool

Source

pub fn is_network(&self) -> bool

Source

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

Returns the originating HTTP status code, when known.

Trait Implementations§

Source§

impl Debug for LeashError

Source§

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

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

impl Display for LeashError

Source§

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

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

impl Error for LeashError

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<Error> for LeashError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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