Rename SqlExceptionNumber to BadRequestSqlExceptionNumber
Clarify intent by renaming SqlExceptionNumber to BadRequestSqlExceptionNumber in both configuration and code. This makes it explicit that these SQL exception numbers are mapped to HTTP 400 Bad Request errors. All relevant usages and settings have been updated accordingly.
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
"RecAction": {
|
||||
"MaxConcurrentInvocations": 5
|
||||
},
|
||||
// SqlException numbers can be updated at runtime; no restart required.
|
||||
// Bad request SqlException numbers numbers can be updated at runtime; no restart required.
|
||||
"SqlException": {
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlexception.number
|
||||
"SqlExceptionNumber": [ 515, 547, 2601, 2627, 50000 ]
|
||||
"BadRequestSqlExceptionNumbers": [ 515, 547, 2601, 2627, 50000 ]
|
||||
},
|
||||
"AddedWho": "ReC.API",
|
||||
"FakeProfileId": 2
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace ReC.Application.Common.Options;
|
||||
|
||||
public class SqlExceptionOptions
|
||||
{
|
||||
public HashSet<int> SqlExceptionNumber { get; set; } = [];
|
||||
public HashSet<int> BadRequestSqlExceptionNumbers { get; set; } = [];
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class DeleteObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlE
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
if (sqlExOpt.CurrentValue.SqlExceptionNumber.Contains(ex.Number))
|
||||
if (sqlExOpt.CurrentValue.BadRequestSqlExceptionNumbers.Contains(ex.Number))
|
||||
throw new BadRequestException(ex.Message, ex);
|
||||
else
|
||||
throw;
|
||||
|
||||
@@ -130,7 +130,7 @@ public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlE
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
if (sqlExOpt.CurrentValue.SqlExceptionNumber.Contains(ex.Number))
|
||||
if (sqlExOpt.CurrentValue.BadRequestSqlExceptionNumbers.Contains(ex.Number))
|
||||
throw new BadRequestException(ex.Message, ex);
|
||||
else
|
||||
throw;
|
||||
|
||||
@@ -142,7 +142,7 @@ public class UpdateObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlE
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
if (sqlExOpt.CurrentValue.SqlExceptionNumber.Contains(ex.Number))
|
||||
if (sqlExOpt.CurrentValue.BadRequestSqlExceptionNumbers.Contains(ex.Number))
|
||||
throw new BadRequestException(ex.Message, ex);
|
||||
else
|
||||
throw;
|
||||
|
||||
Reference in New Issue
Block a user