X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ferrors.rs;h=66ddf84d96871857ed027cc5c3c74f3bfb749dfb;hb=e397cb99601e9d2849bbc3aad2b0df8bc8b7f522;hp=71e5eed67f26abf7892ab698aaf5c723f6fad271;hpb=7743cbdf14412bfbe37fbce787e7b1f9a9a44d53;p=rust-lightning diff --git a/src/util/errors.rs b/src/util/errors.rs index 71e5eed6..66ddf84d 100644 --- a/src/util/errors.rs +++ b/src/util/errors.rs @@ -1,3 +1,5 @@ +//! Error types live here. + use std::fmt; /// Indicates an error on the client's part (usually some variant of attempting to use too-low or @@ -5,18 +7,45 @@ use std::fmt; pub enum APIError { /// Indicates the API was wholly misused (see err for more). Cases where these can be returned /// are documented, but generally indicates some precondition of a function was violated. - APIMisuseError {err: &'static str}, + APIMisuseError { + /// A human-readable error message + err: &'static str + }, /// Due to a high feerate, we were unable to complete the request. /// For example, this may be returned if the feerate implies we cannot open a channel at the /// requested value, but opening a larger channel would succeed. - FeeRateTooHigh {err: String, feerate: u64}, + FeeRateTooHigh { + /// A human-readable error message + err: String, + /// The feerate which was too high. + feerate: u64 + }, + /// A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, + /// too-many-hops, etc). + RouteError { + /// A human-readable error message + err: &'static str + }, + /// We were unable to complete the request as the Channel required to do so is unable to + /// complete the request (or was not found). This can take many forms, including disconnected + /// peer, channel at capacity, channel shutting down, etc. + ChannelUnavailable { + /// A human-readable error message + err: &'static str + }, + /// An attempt to call add_update_monitor returned an Err (ie you did this!), causing the + /// attempted action to fail. + MonitorUpdateFailed, } impl fmt::Debug for APIError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { APIError::APIMisuseError {ref err} => f.write_str(err), - APIError::FeeRateTooHigh {ref err, ref feerate} => write!(f, "{} feerate: {}", err, feerate) + APIError::FeeRateTooHigh {ref err, ref feerate} => write!(f, "{} feerate: {}", err, feerate), + APIError::RouteError {ref err} => f.write_str(err), + APIError::ChannelUnavailable {ref err} => f.write_str(err), + APIError::MonitorUpdateFailed => f.write_str("Client indicated a channel monitor update failed"), } } }