From 3c993aa73c93f0fe335ced78d9709b39cdbd1935 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 6 Nov 2022 14:06:22 +0100 Subject: refactor: improve cast error handling --- src/di_container/asynchronous/mod.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/di_container') diff --git a/src/di_container/asynchronous/mod.rs b/src/di_container/asynchronous/mod.rs index 7dda1d7..89b2fba 100644 --- a/src/di_container/asynchronous/mod.rs +++ b/src/di_container/asynchronous/mod.rs @@ -270,7 +270,12 @@ impl AsyncDIContainer >( )) } - CastError::CastFailed { from: _, to: _ } => { + CastError::CastFailed { + source: _, + from: _, + to: _, + } + | CastError::GetCasterFailed(_) => { AsyncDIContainerError::CastFailed { interface: type_name::(), binding_kind: "singleton", @@ -291,7 +296,12 @@ impl AsyncDIContainer type_name::(), ) } - CastError::CastFailed { from: _, to: _ } => { + CastError::CastFailed { + source: _, + from: _, + to: _, + } + | CastError::GetCasterFailed(_) => { AsyncDIContainerError::CastFailed { interface: type_name::(), binding_kind: "factory", @@ -348,12 +358,15 @@ impl AsyncDIContainer CastError::NotArcCastable(_) => { AsyncDIContainerError::InterfaceNotAsync(type_name::()) } - CastError::CastFailed { from: _, to: _ } => { - AsyncDIContainerError::CastFailed { - interface: type_name::(), - binding_kind, - } + CastError::CastFailed { + source: _, + from: _, + to: _, } + | CastError::GetCasterFailed(_) => AsyncDIContainerError::CastFailed { + interface: type_name::(), + binding_kind, + }, }) } -- cgit v1.2.3-18-g5258