about summary refs log tree commit diff
path: root/src/database/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/database/mod.rs')
-rw-r--r--src/database/mod.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/database/mod.rs b/src/database/mod.rs
index 27c0025..7b144f8 100644
--- a/src/database/mod.rs
+++ b/src/database/mod.rs
@@ -90,12 +90,20 @@ impl serde::Serialize for StorageError {
 impl StorageError {
     /// Create a new StorageError of an ErrorKind with a message.
     fn new(kind: ErrorKind, msg: &str) -> Self {
-        StorageError {
+        Self {
             msg: msg.to_string(),
             source: None,
             kind,
         }
     }
+    /// Create a StorageError using another arbitrary Error as a source.
+    fn with_source(kind: ErrorKind, msg: &str, source: Box<dyn std::error::Error>) -> Self {
+        Self {
+            msg: msg.to_string(),
+            source: Some(source),
+            kind
+        }
+    }
     /// Get the kind of an error.
     pub fn kind(&self) -> ErrorKind {
         self.kind