From: Yuntai Kyong Date: Fri, 17 Aug 2018 03:46:17 +0000 (+0900) Subject: Add APIError enum X-Git-Tag: v0.0.12~347^2~6 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=4553369d2049b2995c664ef7690318a45031788c;p=rust-lightning Add APIError enum `APIMisuse` when paramters passed from the client is invalid `FeeRateTooHigh` when a channel cannot be opened due to high feerate --- diff --git a/src/util/errors.rs b/src/util/errors.rs new file mode 100644 index 000000000..0700b451c --- /dev/null +++ b/src/util/errors.rs @@ -0,0 +1,15 @@ +use std::fmt; + +pub enum APIError { + APIMisuseError {err: &'static str}, + FeeRateTooHigh {err: String, feerate: u64}, +} + +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) + } + } +} diff --git a/src/util/mod.rs b/src/util/mod.rs index 8edd5c770..571a4dbed 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -1,4 +1,5 @@ pub mod events; +pub mod errors; pub(crate) mod byte_utils; pub(crate) mod chacha20poly1305rfc;