Style fixes to tor-bytes errors.
Also note an issue with the design of tor-bytes::Error that should probably go in a separate MR.
This commit is contained in:
parent
7163b7dcc0
commit
3120f1092a
|
@ -3,6 +3,10 @@
|
|||
use thiserror::Error;
|
||||
|
||||
/// Error type for decoding and encoding Tor objects from and to bytes.
|
||||
//
|
||||
// TODO(nickm): This error type could use a redesign: it doesn't do a good job
|
||||
// of preserving context. At the least it should say what kind of object it
|
||||
// found any given problem in.
|
||||
#[derive(Error, Debug, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub enum Error {
|
||||
|
@ -11,23 +15,23 @@ pub enum Error {
|
|||
/// This can mean that the object is truncated, or that we need to
|
||||
/// read more and try again, depending on the context in which it
|
||||
/// was received.
|
||||
#[error("object truncated (or not fully present)")]
|
||||
#[error("Object truncated (or not fully present)")]
|
||||
Truncated,
|
||||
/// Called Reader::should_be_exhausted(), but found bytes anyway.
|
||||
#[error("extra bytes at end of object")]
|
||||
#[error("Extra bytes at end of object")]
|
||||
ExtraneousBytes,
|
||||
/// Invalid length value (eg, overflow)
|
||||
#[error("bad length value")]
|
||||
#[error("Object length out of bounds")]
|
||||
BadLengthValue,
|
||||
/// An attempt to parse an object failed for some reason related to its
|
||||
/// contents.
|
||||
#[error("bad object: {0}")]
|
||||
#[error("Bad object: {0}")]
|
||||
BadMessage(&'static str),
|
||||
/// A parsing error that should never happen.
|
||||
///
|
||||
/// We use this one in lieu of calling assert() and expect() and
|
||||
/// unwrap() from within parsing code.
|
||||
#[error("bug")]
|
||||
#[error("Internal error")]
|
||||
Bug(#[from] tor_error::Bug),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue