enhan(errors): make StorageErrorExt generic on errors (#928)

This commit is contained in:
Abhishek
2023-04-21 02:53:18 +05:30
committed by GitHub
parent 891683e060
commit e161d92c58

View File

@ -1,20 +1,16 @@
use crate::{core::errors, logger}; use crate::{core::errors, logger};
pub trait StorageErrorExt<T> { pub trait StorageErrorExt<T, E> {
#[track_caller] #[track_caller]
fn to_not_found_response( fn to_not_found_response(self, not_found_response: E) -> error_stack::Result<T, E>;
self,
not_found_response: errors::ApiErrorResponse,
) -> error_stack::Result<T, errors::ApiErrorResponse>;
#[track_caller] #[track_caller]
fn to_duplicate_response( fn to_duplicate_response(self, duplicate_response: E) -> error_stack::Result<T, E>;
self,
duplicate_response: errors::ApiErrorResponse,
) -> error_stack::Result<T, errors::ApiErrorResponse>;
} }
impl<T> StorageErrorExt<T> for error_stack::Result<T, errors::StorageError> { impl<T> StorageErrorExt<T, errors::ApiErrorResponse>
for error_stack::Result<T, errors::StorageError>
{
#[track_caller] #[track_caller]
fn to_not_found_response( fn to_not_found_response(
self, self,