]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add APIError enum
authorYuntai Kyong <yuntai.kyong@gmail.com>
Fri, 17 Aug 2018 03:46:17 +0000 (12:46 +0900)
committerMatt Corallo <git@bluematt.me>
Fri, 17 Aug 2018 17:09:30 +0000 (13:09 -0400)
`APIMisuse` when paramters passed from the client is invalid
`FeeRateTooHigh` when a channel cannot be opened due to high feerate

src/util/errors.rs [new file with mode: 0644]
src/util/mod.rs

diff --git a/src/util/errors.rs b/src/util/errors.rs
new file mode 100644 (file)
index 0000000..0700b45
--- /dev/null
@@ -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)
+               }
+  }
+}
index 8edd5c7709ccd554cad50da3822209cf053a8475..571a4dbed1010049c2cd7590df55397a221af39c 100644 (file)
@@ -1,4 +1,5 @@
 pub mod events;
+pub mod errors;
 
 pub(crate) mod byte_utils;
 pub(crate) mod chacha20poly1305rfc;