summaryrefslogtreecommitdiff
path: root/src/utils/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/error.rs')
-rw-r--r--src/utils/error.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/utils/error.rs b/src/utils/error.rs
index 4f044ca..7fafea1 100644
--- a/src/utils/error.rs
+++ b/src/utils/error.rs
@@ -138,6 +138,28 @@ impl Error {
status_code,
}))
}
+
+ /// Sanitizes public-facing errors that can leak sensitive information.
+ pub fn sanitized_error(&self) -> String {
+ let db_error = String::from("Database or I/O error occurred.");
+
+ match self {
+ #[cfg(feature = "sled")]
+ Self::SledError { .. } => db_error,
+ #[cfg(feature = "sqlite")]
+ Self::SqliteError { .. } => db_error,
+ #[cfg(feature = "persy")]
+ Self::PersyError { .. } => db_error,
+ #[cfg(feature = "heed")]
+ Self::HeedError => db_error,
+ #[cfg(feature = "rocksdb")]
+ Self::RocksDbError { .. } => db_error,
+ Self::IoError { .. } => db_error,
+ Self::BadConfig { .. } => db_error,
+ Self::BadDatabase { .. } => db_error,
+ _ => self.to_string(),
+ }
+ }
}
#[cfg(feature = "persy")]