op_store: make OpStoreError::Other preserve source error object

This is the OpStore version of e1e75daa8e.
This commit is contained in:
Martin von Zweigbergk 2023-07-26 10:27:43 -07:00 committed by Martin von Zweigbergk
parent 60d48c27f6
commit 769426f99a
2 changed files with 5 additions and 5 deletions

View file

@ -380,8 +380,8 @@ content_hash! {
pub enum OpStoreError {
#[error("Operation not found")]
NotFound,
#[error("{0}")]
Other(String),
#[error(transparent)]
Other(Box<dyn std::error::Error + Send + Sync>),
}
pub type OpStoreResult<T> = Result<T, OpStoreError>;

View file

@ -32,19 +32,19 @@ use crate::op_store::{
impl From<std::io::Error> for OpStoreError {
fn from(err: std::io::Error) -> Self {
OpStoreError::Other(err.to_string())
OpStoreError::Other(err.into())
}
}
impl From<PersistError> for OpStoreError {
fn from(err: PersistError) -> Self {
OpStoreError::Other(err.to_string())
OpStoreError::Other(err.into())
}
}
impl From<prost::DecodeError> for OpStoreError {
fn from(err: prost::DecodeError) -> Self {
OpStoreError::Other(err.to_string())
OpStoreError::Other(err.into())
}
}