diff options
Diffstat (limited to 'tvix/store/src/errors.rs')
-rw-r--r-- | tvix/store/src/errors.rs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/tvix/store/src/errors.rs b/tvix/store/src/errors.rs deleted file mode 100644 index 3b23f972b045..000000000000 --- a/tvix/store/src/errors.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::sync::PoisonError; -use thiserror::Error; -use tokio::task::JoinError; -use tonic::Status; - -/// Errors related to communication with the store. -#[derive(Debug, Error)] -pub enum Error { - #[error("invalid request: {0}")] - InvalidRequest(String), - - #[error("internal storage error: {0}")] - StorageError(String), -} - -impl<T> From<PoisonError<T>> for Error { - fn from(value: PoisonError<T>) -> Self { - Error::StorageError(value.to_string()) - } -} - -impl From<JoinError> for Error { - fn from(value: JoinError) -> Self { - Error::StorageError(value.to_string()) - } -} - -impl From<Error> for Status { - fn from(value: Error) -> Self { - match value { - Error::InvalidRequest(msg) => Status::invalid_argument(msg), - Error::StorageError(msg) => Status::data_loss(format!("storage error: {}", msg)), - } - } -} - -// TODO: this should probably go somewhere else? -impl From<Error> for std::io::Error { - fn from(value: Error) -> Self { - match value { - Error::InvalidRequest(msg) => Self::new(std::io::ErrorKind::InvalidInput, msg), - Error::StorageError(msg) => Self::new(std::io::ErrorKind::Other, msg), - } - } -} |