Skip to main content

sova_storage/
error.rs

1use sova_core::extend::ErrorResponse;
2use sova_core::{Error, IntoResponse, Response};
3
4#[derive(Debug, thiserror::Error)]
5pub enum StorageError {
6    #[error("{0}")]
7    Msg(String),
8    #[error(transparent)]
9    Io(#[from] std::io::Error),
10}
11
12impl From<StorageError> for Error {
13    fn from(err: StorageError) -> Self {
14        Error::Internal(err.to_string())
15    }
16}
17
18impl IntoResponse for StorageError {
19    fn into_response(self) -> Response {
20        Error::from(self).into_response()
21    }
22}
23
24impl ErrorResponse for StorageError {}
25
26#[cfg(any(feature = "s3", feature = "gcs", feature = "azure"))]
27impl From<opendal::Error> for StorageError {
28    fn from(err: opendal::Error) -> Self {
29        StorageError::Msg(err.to_string())
30    }
31}