diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/database/mod.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/database/mod.rs b/src/database/mod.rs index 4e74c8f..339439d 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -46,13 +46,10 @@ pub enum ErrorKind { #[derive(Debug)] pub struct StorageError { msg: String, - source: Option<Box<dyn std::error::Error>>, + source: Option<Box<dyn std::error::Error + Send + Sync>>, kind: ErrorKind, } -// XXX figure out what makes this un-sendable by default -// and if it's sound to mark StorageError as Send & Sync -unsafe impl Send for StorageError {} -unsafe impl Sync for StorageError {} + impl From<StorageError> for tide::Response { fn from(err: StorageError) -> Self { tide::Response::builder(match err.kind() { @@ -73,7 +70,7 @@ impl From<StorageError> for tide::Response { } impl std::error::Error for StorageError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - self.source.as_ref().map(|e| e.as_ref()) + self.source.as_ref().map(|e| e.as_ref() as &dyn std::error::Error) } } impl From<serde_json::Error> for StorageError { @@ -118,7 +115,7 @@ impl StorageError { } } /// Create a StorageError using another arbitrary Error as a source. - fn with_source(kind: ErrorKind, msg: &str, source: Box<dyn std::error::Error>) -> Self { + fn with_source(kind: ErrorKind, msg: &str, source: Box<dyn std::error::Error + Send + Sync>) -> Self { Self { msg: msg.to_string(), source: Some(source), |