Skip to content

Commit 9b80267

Browse files
authored
add root exception expander (#621)
1 parent f1b4310 commit 9b80267

6 files changed

Lines changed: 25 additions & 6 deletions

File tree

src/Database/Framework.Database.NHibernate.Runtime/SqlExceptionProcessors/SqlExceptionProcessorInterceptor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ internal class SqlExceptionProcessorInterceptor : IExceptionExpander
2121

2222
internal SqlExceptionProcessorInterceptor(ISessionFactory factory, Configuration cfg, IDalValidationIdentitySource dalValidationIdentitySource)
2323
{
24-
25-
2624
this.cfg = cfg;
2725
this.dalValidationIdentitySource = dalValidationIdentitySource;
2826
var connectionString = ((SessionFactoryImpl)factory).ConnectionProvider.GetConnection().ConnectionString;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
/// </summary>
66
public interface IExceptionExpander
77
{
8+
public const string ElementKey = "Element";
9+
810
/// <summary>
911
/// Пыпытка раскрытие исключения
1012
/// </summary>

src/Infrastructure/Framework.Infrastructure.Legacy/DependencyInjection/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public IServiceCollection AddLegacyGenericServices()
5656
services.ReplaceSingleton<IActualDomainTypeResolver, ProjectionActualDomainTypeResolver>();
5757
services.ReplaceSingleton<ISecurityContextInfoSource, ProjectionSecurityContextInfoSource>();
5858

59-
services.AddSingleton<IExceptionExpander, TargetInvocationExceptionExpander>();
59+
services.AddKeyedSingleton<IExceptionExpander, TargetInvocationExceptionExpander>(IExceptionExpander.ElementKey);
6060

6161
services.AddSingleton(new WebApiExceptionExpanderSettings([typeof(ValidationException)]));
6262

src/Infrastructure/Framework.Infrastructure/DependencyInjection/BssFrameworkSetup.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
using Framework.Application.Auth;
66
using Framework.Application.DependencyInjection;
77
using Framework.Application.Events;
8+
using Framework.Core;
89
using Framework.Database.DALListener;
910
using Framework.Database.DependencyInjection;
1011

1112
using Framework.Infrastructure.Auth;
1213
using Framework.Infrastructure.DALListener;
1314
using Framework.Infrastructure.Integration;
1415
using Framework.Infrastructure.Middleware;
16+
using Framework.Infrastructure.Services;
1517
using Framework.Infrastructure.WebApiExceptionExpander;
1618

1719
using Microsoft.Extensions.DependencyInjection;
@@ -88,6 +90,8 @@ public IBssFrameworkSetup SetDomainObjectEventMetadata<T>()
8890

8991
public void Initialize(IServiceCollection services)
9092
{
93+
services.AddSingleton<IExceptionExpander, RootExceptionExpander>();
94+
9195
services.AddSingleton<ICultureSource>(CultureSource.CurrentCulture);
9296

9397
services.AddGenericApplicationServices();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Framework.Core;
2+
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
namespace Framework.Infrastructure.Services;
6+
7+
public class RootExceptionExpander([FromKeyedServices(IExceptionExpander.ElementKey)] IEnumerable<IExceptionExpander> exceptionExpanders) : IExceptionExpander
8+
{
9+
public Exception? TryExpand(Exception exception)
10+
{
11+
var result = exceptionExpanders.Aggregate(exception, (state, expander) => expander.Expand(state));
12+
13+
return result == exception ? null : result;
14+
}
15+
}

src/__SolutionItems/CommonAssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
[assembly: AssemblyCompany("Luxoft")]
55
[assembly: AssemblyCopyright("Copyright © Luxoft 2009-2026")]
66

7-
[assembly: AssemblyVersion("27.0.1.0")]
8-
[assembly: AssemblyFileVersion("27.0.1.0")]
9-
[assembly: AssemblyInformationalVersion("27.0.1.0")]
7+
[assembly: AssemblyVersion("27.0.2.0")]
8+
[assembly: AssemblyFileVersion("27.0.2.0")]
9+
[assembly: AssemblyInformationalVersion("27.0.2.0")]
1010

1111
#if DEBUG
1212
[assembly: AssemblyConfiguration("Debug")]

0 commit comments

Comments
 (0)