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
ConnectionRequired
HTTP 403 — the user hasn’t connected this integration yet.
Fields
UpgradeRequired
HTTP 402 surfaced from env.get — Growth plan or above is required.
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.
HTTP 401 — missing or invalid credential.
Fields
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
MalformedResponse
Platform returned a response we couldn’t deserialise.
Implementations§
Source§impl LeashError
impl LeashError
Sourcepub fn is_plan_block(&self) -> bool
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.
Sourcepub fn is_upgrade_required(&self) -> bool
pub fn is_upgrade_required(&self) -> bool
Alias of Self::is_plan_block matching the TS / Go naming.
Sourcepub fn is_connection_required(&self) -> bool
pub fn is_connection_required(&self) -> bool
True for LeashError::ConnectionRequired.
True for LeashError::Unauthorized.
Sourcepub fn is_key_not_declared(&self) -> bool
pub fn is_key_not_declared(&self) -> bool
True for LeashError::KeyNotDeclared.
Sourcepub fn is_network(&self) -> bool
pub fn is_network(&self) -> bool
True for LeashError::Network.
Trait Implementations§
Source§impl Debug for LeashError
impl Debug for LeashError
Source§impl Display for LeashError
impl Display for LeashError
Source§impl Error for LeashError
impl Error for LeashError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for LeashError
impl !RefUnwindSafe for LeashError
impl Send for LeashError
impl Sync for LeashError
impl Unpin for LeashError
impl UnsafeUnpin for LeashError
impl !UnwindSafe for LeashError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.