#[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
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.
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
limit_seconds: u64The 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
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
impl Error
Sourcepub fn code(&self) -> ErrorCode
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 Error for Error
impl Error for Error
1.30.0 · 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()
Source§impl From<BlockError> for Error
impl From<BlockError> for Error
Source§fn from(error: BlockError) -> Self
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.