diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Features.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Features.cs index 064912eb0..072ad1fcc 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Features.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Features.cs @@ -23,7 +23,7 @@ public static class PostgreSqlProvidersExtensions public static EFCoreIdentityPersistenceFeature UsePostgreSql(this EFCoreIdentityPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default) { feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(Assembly, connectionString, options); - feature.DbExceptionHandler = _ => new DbExceptionHandler(); + feature.DbExceptionHandler = _ => new DbExceptionTransformer(); return feature; } @@ -33,7 +33,7 @@ public static class PostgreSqlProvidersExtensions public static EFCoreAlterationsPersistenceFeature UsePostgreSql(this EFCoreAlterationsPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default) { feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(Assembly, connectionString, options); - feature.DbExceptionHandler = _ => new DbExceptionHandler(); + feature.DbExceptionHandler = _ => new DbExceptionTransformer(); return feature; } @@ -43,7 +43,7 @@ public static class PostgreSqlProvidersExtensions public static EFCoreLabelPersistenceFeature UsePostgreSql(this EFCoreLabelPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default) { feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(Assembly, connectionString, options); - feature.DbExceptionHandler = _ => new DbExceptionHandler(); + feature.DbExceptionHandler = _ => new DbExceptionTransformer(); return feature; } @@ -53,7 +53,7 @@ public static class PostgreSqlProvidersExtensions public static EFCoreWorkflowDefinitionPersistenceFeature UsePostgreSql(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default) { feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(Assembly, connectionString, options); - feature.DbExceptionHandler = _ => new DbExceptionHandler(); + feature.DbExceptionHandler = _ => new DbExceptionTransformer(); return feature; } @@ -63,7 +63,7 @@ public static class PostgreSqlProvidersExtensions public static EFCoreWorkflowInstancePersistenceFeature UsePostgreSql(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default) { feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(Assembly, connectionString, options); - feature.DbExceptionHandler = _ => new DbExceptionHandler(); + feature.DbExceptionHandler = _ => new DbExceptionTransformer(); return feature; } @@ -73,7 +73,7 @@ public static class PostgreSqlProvidersExtensions public static WorkflowManagementPersistenceFeature UsePostgreSql(this WorkflowManagementPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default) { feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(Assembly, connectionString, options); - feature.DbExceptionHandler = _ => new DbExceptionHandler(); + feature.DbExceptionHandler = _ => new DbExceptionTransformer(); return feature; } @@ -83,7 +83,7 @@ public static class PostgreSqlProvidersExtensions public static EFCoreWorkflowRuntimePersistenceFeature UsePostgreSql(this EFCoreWorkflowRuntimePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default) { feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(Assembly, connectionString, options); - feature.DbExceptionHandler = _ => new DbExceptionHandler(); + feature.DbExceptionHandler = _ => new DbExceptionTransformer(); return feature; } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Handlers/DbExceptionHandler.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Handlers/DbExceptionTransformer.cs similarity index 73% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Handlers/DbExceptionHandler.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Handlers/DbExceptionTransformer.cs index f23150beb..b822bc3e8 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Handlers/DbExceptionHandler.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Handlers/DbExceptionTransformer.cs @@ -10,16 +10,14 @@ using Npgsql; namespace Elsa.EntityFrameworkCore.PostgreSql.Handlers; -/// -/// Handles database exceptions encountered when using a postgreSQL database. -/// -public class DbExceptionHandler : IDbExceptionHandler, +/// Transforms database exceptions encountered when using a postgreSQL database into more generic exceptions. +public class DbExceptionTransformer : IDbExceptionHandler, IDbExceptionHandler, IDbExceptionHandler, IDbExceptionHandler, IDbExceptionHandler { - /// Handles database exceptions encountered when using a postgreSQL database. + /// Transforms database exceptions encountered when using a postgreSQL database into more generic exceptions. public void Handle(DbUpdateException exception) { var ex = exception.InnerException as PostgresException; diff --git a/src/modules/Elsa.EntityFrameworkCore/Handlers/NoopDbExceptionHandler.cs b/src/modules/Elsa.EntityFrameworkCore/Handlers/RethrowDbExceptionHandler.cs similarity index 73% rename from src/modules/Elsa.EntityFrameworkCore/Handlers/NoopDbExceptionHandler.cs rename to src/modules/Elsa.EntityFrameworkCore/Handlers/RethrowDbExceptionHandler.cs index 7fb04ecb7..03a9f72a1 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Handlers/NoopDbExceptionHandler.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Handlers/RethrowDbExceptionHandler.cs @@ -8,14 +8,14 @@ using Microsoft.EntityFrameworkCore; namespace Elsa.EntityFrameworkCore.Handlers; -/// A No-Op database exception handler. -public class NoopDbExceptionHandler : IDbExceptionHandler, +/// A database exception handler that rethrows the original exception. +public class RethrowDbExceptionHandler : IDbExceptionHandler, IDbExceptionHandler, IDbExceptionHandler, IDbExceptionHandler, IDbExceptionHandler { - /// Handles the given exception that occurs during database operations. + /// rethrows the given exception that occurs during database operations. public void Handle(DbUpdateException exception) { throw exception; diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Alterations/Feature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Alterations/Feature.cs index d2d18bcd7..7354d6233 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Alterations/Feature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Alterations/Feature.cs @@ -16,7 +16,7 @@ namespace Elsa.EntityFrameworkCore.Modules.Alterations; public class EFCoreAlterationsPersistenceFeature(IModule module) : PersistenceFeatureBase(module) { /// Delegate for determining the exception handler. - public Func> DbExceptionHandler { get; set; } = _ => new NoopDbExceptionHandler(); + public Func> DbExceptionHandler { get; set; } = _ => new RethrowDbExceptionHandler(); /// public override void Configure() diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/Feature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/Feature.cs index c370c89d8..628633736 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/Feature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/Feature.cs @@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Modules.Identity; public class EFCoreIdentityPersistenceFeature(IModule module) : PersistenceFeatureBase(module) { /// Delegate for determining the exception handler. - public Func> DbExceptionHandler { get; set; } = _ => new NoopDbExceptionHandler(); + public Func> DbExceptionHandler { get; set; } = _ => new RethrowDbExceptionHandler(); /// public override void Configure() diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs index 462d55b3a..977d6f5df 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs @@ -14,7 +14,7 @@ namespace Elsa.EntityFrameworkCore.Modules.Labels; public class EFCoreLabelPersistenceFeature(IModule module) : PersistenceFeatureBase(module) { /// Delegate for determining the exception handler. - public Func> DbExceptionHandler { get; set; } = _ => new NoopDbExceptionHandler(); + public Func> DbExceptionHandler { get; set; } = _ => new RethrowDbExceptionHandler(); public override void Configure() { diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs index 6c4a28c54..b89ce2cab 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs @@ -16,7 +16,7 @@ namespace Elsa.EntityFrameworkCore.Modules.Management; public class EFCoreWorkflowDefinitionPersistenceFeature(IModule module) : PersistenceFeatureBase(module) { /// Delegate for determining the exception handler. - public Func> DbExceptionHandler { get; set; } = _ => new NoopDbExceptionHandler(); + public Func> DbExceptionHandler { get; set; } = _ => new RethrowDbExceptionHandler(); /// public override void Configure() diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs index aebdfc924..7fbfe7869 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs @@ -16,7 +16,7 @@ namespace Elsa.EntityFrameworkCore.Modules.Management; public class EFCoreWorkflowInstancePersistenceFeature(IModule module) : PersistenceFeatureBase(module) { /// Delegate for determining the exception handler. - public Func> DbExceptionHandler { get; set; } = _ => new NoopDbExceptionHandler(); + public Func> DbExceptionHandler { get; set; } = _ => new RethrowDbExceptionHandler(); /// public override void Configure() diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowManagementPersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowManagementPersistenceFeature.cs index f73185bb7..dd937a7d7 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowManagementPersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowManagementPersistenceFeature.cs @@ -20,7 +20,7 @@ namespace Elsa.EntityFrameworkCore.Modules.Management; public class WorkflowManagementPersistenceFeature(IModule module) : PersistenceFeatureBase(module) { /// Delegate for determining the exception handler. - public Func> DbExceptionHandler { get; set; } = _ => new NoopDbExceptionHandler(); + public Func> DbExceptionHandler { get; set; } = _ => new RethrowDbExceptionHandler(); /// public override void Configure() diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowRuntimePersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowRuntimePersistenceFeature.cs index caf87fb14..2db68cf11 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowRuntimePersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowRuntimePersistenceFeature.cs @@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Modules.Runtime; public class EFCoreWorkflowRuntimePersistenceFeature(IModule module) : PersistenceFeatureBase(module) { /// Delegate for determining the exception handler. - public Func> DbExceptionHandler { get; set; } = _ => new NoopDbExceptionHandler(); + public Func> DbExceptionHandler { get; set; } = _ => new RethrowDbExceptionHandler(); /// public override void Configure()