From 4553369d2049b2995c664ef7690318a45031788c Mon Sep 17 00:00:00 2001 From: Yuntai Kyong Date: Fri, 17 Aug 2018 12:46:17 +0900 Subject: [PATCH] Add APIError enum `APIMisuse` when paramters passed from the client is invalid `FeeRateTooHigh` when a channel cannot be opened due to high feerate --- src/util/errors.rs | 15 +++++++++++++++ src/util/mod.rs | 1 + 2 files changed, 16 insertions(+) create mode 100644 src/util/errors.rs 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; -- 2.39.5