Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 13 variants Transport(String), Handshake, Timeout, LiteServer { code: i32, message: String, }, Decode(String), Address(String), Config(String), Cell(String), Proof(String), Sync(String), Stale { age_seconds: u64, limit_seconds: u64, }, ClockBehind { by_seconds: u64, tolerated_seconds: u64, }, ConnectionLost,
}
Expand description

The error type for every fallible operation in this crate.

A closed, #[non_exhaustive] enum: variants can be added before 1.0 without a breaking change. The lower crates’ narrow errors are mapped into this set.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Transport(String)

A transport failure: a socket could not connect, read, or write.

§

Handshake

The ADNL handshake with a liteserver failed.

§

Timeout

A query did not complete within its deadline.

§

LiteServer

The liteserver returned an error response.

Fields

§code: i32

The liteserver error code.

§message: String

The liteserver error message.

§

Decode(String)

A wire value could not be decoded, or a frame checksum did not match.

§

Address(String)

An address string was not a valid address.

§

Config(String)

A config could not be parsed.

§

Cell(String)

A cell, a bag of cells, or a structure built from them could not be read.

§

Proof(String)

A proof did not check out, or the account did not bind to the trusted block.

A read that fails this way returns no value at all. There is no partial result and no unproven fallback: a verified read either proves what it returns or fails.

§

Sync(String)

A block proof chain did not establish a block to trust.

Separate from Proof because the two fail at different stages. A proof failure means a server’s answer did not match a block the client already trusts; a sync failure means the client never established that block at all, and retrying against another server is a reasonable response to one and not the other.

§

Stale

The newest block the server could prove is older than the freshness bound.

The one failure here where the server may be honest and merely behind. A liteserver can serve a real, fully proved block that is simply old, and nothing inside a proof says when it was served.

Fields

§age_seconds: u64

How far behind the local clock the proven head is.

§limit_seconds: u64

The bound that was exceeded, from crate::Config::max_head_age.

§

ClockBehind

The local clock is far enough behind the chain that freshness cannot be judged.

Validators do not sign blocks from the future, so a proven block well ahead of the local clock places the fault on this side. It is reported rather than ignored because the freshness check is what separates a current block from a genuine old one replayed, and a clock this wrong silently switches it off. The remedy is a correct clock, not another server.

Fields

§by_seconds: u64

How far the proven block is ahead of the local clock.

§tolerated_seconds: u64

The drift that is tolerated before this is reported.

§

ConnectionLost

The session lost its place in the byte stream and cannot be used again.

The ADNL ciphers are a counter the two ends advance in step, so a frame that only half moved leaves this side unable to read anything further. Abandoning a call at its deadline is one way to get here. A caller opens a new client; retrying on this one fails the same way every time.

Implementations§

Source§

impl Error

Source

pub fn code(&self) -> ErrorCode

Which kind of failure this is, as a name a caller can branch on.

The match below is exhaustive on purpose. #[non_exhaustive] binds callers outside this crate and not this file, so a variant added without a code here fails to compile rather than reaching a caller unnamed. That is the whole mechanism: before this existed the mapping was a wildcard inside the Node binding, and a new variant would have arrived in JavaScript as UNKNOWN.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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

Source§

fn from(error: AdnlError) -> Self

Converts to this type from the input type.
Source§

impl From<BlockError> for Error

Source§

fn from(error: BlockError) -> Self

Every way the proof engine fails is a proof failure, bytes that are not cells included.

The tempting split is to call unparsable bytes a decode failure, on the reasoning that they failed before any proof was in question. They did not: the bytes are the server’s proof, and the engine parses them with no precondition, so four bytes of junk in a shard proof is a server failing to prove its answer in the cheapest way available. A caller deciding whether to keep asking this server needs both to arrive as the same kind of failure.

A read that verified nothing must not use this. It has a classifier of its own, so a failure out of one stays a failure to read bytes.

Source§

impl From<LiteError> for Error

Source§

fn from(error: LiteError) -> Self

Converts to this type from the input type.
Source§

impl From<TransportError> for Error

Source§

fn from(error: TransportError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.