pub enum Error {
Io(Error),
Config {
file: String,
line: usize,
message: String,
},
Json {
line: usize,
column: usize,
message: String,
},
Template {
file: String,
line: usize,
column: usize,
message: String,
},
Protocol(String),
Unavailable(String),
Message(String),
}Expand description
Every failure the framework itself can produce.
Application errors are expected to convert into this through From, which
is what lets a handler return Result<T, E> and still be a valid handler.
Variants§
Io(Error)
A file could not be read or written.
Config
A .env or config file was malformed.
Json
A JSON document could not be parsed.
Template
A template could not be parsed or rendered.
Carries the position because a view is written by hand, often by someone who is not the person reading the stack trace.
Protocol(String)
A malformed HTTP request reached the parser.
A dependency was not tried, because it is known to be failing.
Distinct from a failure on purpose: nothing was sent, so nothing can
have had an effect, and a caller may safely fall back to a cache, a
default, or a degraded answer. Raised by the circuit breaker in
rustlavel-client.
Message(String)
Anything raised by application code.
Implementations§
Trait Implementations§
Source§impl Debug for Error
Deliberately the same as Display.
impl Debug for Error
Deliberately the same as Display.
Rust prints the error a main returns with Debug, not Display, so the
derived form is what people actually see when an application fails to
start. It reads like this:
Error: Io(Os { code: 48, kind: AddrInUse, message: "Address already in use" })which names the struct that holds the problem rather than the problem, and
tells somebody nothing they can act on. Delegating to Display gives them
the sentence that was written for them instead. Test output improves for
the same reason: unwrap_err() on a bad config now says which file and
line, not which variant.
Source§impl Error for Error
impl Error for Error
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()