aboutsummaryrefslogtreecommitdiff
path: root/lockchain-core/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lockchain-core/src/errors.rs')
-rw-r--r--lockchain-core/src/errors.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/lockchain-core/src/errors.rs b/lockchain-core/src/errors.rs
index 18f23f3..6a5b632 100644
--- a/lockchain-core/src/errors.rs
+++ b/lockchain-core/src/errors.rs
@@ -8,9 +8,12 @@
//! turning a `VaultAlreadyExists` failure to
//! a `FailedInitialise`.
+use std::error;
+use std::fmt::{Display, Formatter, Result};
+
/// A collection of common error codes that can be
/// returned by lockchain API functions
-#[derive(Serialize, Deserialize)]
+#[derive(Debug, Serialize, Deserialize)]
pub enum Error {
/// Creating a vault where one already exists
VaultAlreadyExists,
@@ -35,3 +38,26 @@ pub enum Error {
// #[hidden_docs]
__NonExhaustive,
}
+
+impl error::Error for Error {}
+
+impl Display for Error {
+ fn fmt(&self, f: &mut Formatter) -> Result {
+ write!(
+ f,
+ "{}",
+ match self {
+ Error::VaultAlreadyExists => "Vault already exists",
+ Error::InvalidPath => "Path invalid",
+ Error::InvalidName => "Name invalid",
+ Error::InvalidCryptoLayer => "Cryptography layer incompatible",
+ Error::FailedCrypto => "Failed cryptographic operation",
+ Error::FailedSelfTest => "Failed self text",
+ Error::FailedLoading => "Failed to load",
+ Error::FailedInitalise => "Failed to initialise",
+ Error::FailedCreation => "Failed to create",
+ _ => "Unknown failure",
+ }
+ )
+ }
+}