Skip to content

Commit

Permalink
enhan(errors): make StorageErrorExt generic on errors (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhicodes-crypto authored Apr 20, 2023
1 parent 891683e commit e161d92
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions crates/router/src/core/errors/utils.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
use crate::{core::errors, logger};

pub trait StorageErrorExt<T> {
pub trait StorageErrorExt<T, E> {
#[track_caller]
fn to_not_found_response(
self,
not_found_response: errors::ApiErrorResponse,
) -> error_stack::Result<T, errors::ApiErrorResponse>;
fn to_not_found_response(self, not_found_response: E) -> error_stack::Result<T, E>;

#[track_caller]
fn to_duplicate_response(
self,
duplicate_response: errors::ApiErrorResponse,
) -> error_stack::Result<T, errors::ApiErrorResponse>;
fn to_duplicate_response(self, duplicate_response: E) -> error_stack::Result<T, E>;
}

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]
fn to_not_found_response(
self,
Expand Down

0 comments on commit e161d92

Please sign in to comment.