Skip to content

Commit

Permalink
Handle injiection point exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mewlist committed Feb 21, 2024
1 parent 166bc6d commit dd5143f
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions Runtime/DIContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,22 @@ private async ValueTask<object> InstantiateInternalAsync(Type targetType, object
AfterInjectionProcessingScope.Begin();

var target = await ConstructorInjector.DoInject(targetType, args, scopedInstances);
var targetMethodsInfo = GetTargetMethodInfo(targetType);
var targetPropertiesInfo = GetTargetPropertyInfo(targetType);
var targetFieldsInfo = GetTargetFieldInfo(targetType);

TargetMethodsInfo targetMethodsInfo;
TargetPropertiesInfo targetPropertiesInfo;
TargetFieldsInfo targetFieldsInfo;
try
{
targetMethodsInfo = GetTargetMethodInfo(targetType);
targetPropertiesInfo = GetTargetPropertyInfo(targetType);
targetFieldsInfo = GetTargetFieldInfo(targetType);
}
catch (Exception e)
{
InjectionProcessingScope.End();
AfterInjectionProcessingScope.End();
throw new FailedToInjectException(target, e);
}

try
{
Expand Down Expand Up @@ -275,9 +288,21 @@ private async ValueTask InjectIntoInternalAsync<T>(T target, object[] args, Scop
AfterInjectionProcessingScope.Begin();

var targetType = target.GetType();
var targetMethodsInfo = GetTargetMethodInfo(targetType);
var targetPropertiesInfo = GetTargetPropertyInfo(targetType);
var targetFieldsInfo = GetTargetFieldInfo(targetType);
TargetMethodsInfo targetMethodsInfo;
TargetPropertiesInfo targetPropertiesInfo;
TargetFieldsInfo targetFieldsInfo;
try
{
targetMethodsInfo = GetTargetMethodInfo(targetType);
targetPropertiesInfo = GetTargetPropertyInfo(targetType);
targetFieldsInfo = GetTargetFieldInfo(targetType);
}
catch (Exception e)
{
InjectionProcessingScope.End();
AfterInjectionProcessingScope.End();
throw new FailedToInjectException(target, e);
}

try
{
Expand Down

0 comments on commit dd5143f

Please sign in to comment.