Skip to content

Commit b71b0b3

Browse files
authored
Improved exception handlers (#40)
1 parent 3148d0e commit b71b0b3

18 files changed

Lines changed: 215 additions & 373 deletions

src/DfE.ExternalApplications.Application/DfE.ExternalApplications.Application.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="GovUK.Dfe.ExternalApplications.Api.Client" Version="0.1.15" />
10+
<PackageReference Include="GovUK.Dfe.ExternalApplications.Api.Client" Version="0.1.17" />
1111
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.3.0" />
1212
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.3.0" />
1313
</ItemGroup>
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using DfE.ExternalApplications.Domain.Models;
1+
//using DfE.ExternalApplications.Domain.Models;
22

3-
namespace DfE.ExternalApplications.Application.Interfaces;
3+
//namespace DfE.ExternalApplications.Application.Interfaces;
44

5-
/// <summary>
6-
/// Provides parsing capabilities for API error responses
7-
/// </summary>
8-
public interface IApiErrorParser
9-
{
10-
/// <summary>
11-
/// Parses an exception to extract structured API error information
12-
/// </summary>
13-
/// <param name="exception">The exception containing the API error</param>
14-
/// <returns>Parsed API error information</returns>
15-
ApiErrorParsingResult ParseApiError(Exception exception);
16-
}
5+
///// <summary>
6+
///// Provides parsing capabilities for API error responses
7+
///// </summary>
8+
//public interface IApiErrorParser
9+
//{
10+
// /// <summary>
11+
// /// Parses an exception to extract structured API error information
12+
// /// </summary>
13+
// /// <param name="exception">The exception containing the API error</param>
14+
// /// <returns>Parsed API error information</returns>
15+
// ApiErrorParsingResult ParseApiError(Exception exception);
16+
//}
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
using DfE.ExternalApplications.Domain.Models;
2-
using Microsoft.AspNetCore.Mvc.ModelBinding;
1+
//using DfE.ExternalApplications.Domain.Models;
2+
//using Microsoft.AspNetCore.Mvc.ModelBinding;
33

4-
namespace DfE.ExternalApplications.Application.Interfaces;
4+
//namespace DfE.ExternalApplications.Application.Interfaces;
55

6-
/// <summary>
7-
/// Handles mapping of API errors to model state validation errors
8-
/// </summary>
9-
public interface IModelStateErrorHandler
10-
{
11-
/// <summary>
12-
/// Adds API validation errors to the model state with proper field mapping
13-
/// </summary>
14-
/// <param name="modelState">The model state to add errors to</param>
15-
/// <param name="apiError">The parsed API error response</param>
16-
/// <param name="fieldMappings">Optional mapping of API field names to model property names</param>
17-
void AddApiErrorsToModelState(ModelStateDictionary modelState, ApiErrorResponse apiError,
18-
Dictionary<string, string>? fieldMappings = null);
6+
///// <summary>
7+
///// Handles mapping of API errors to model state validation errors
8+
///// </summary>
9+
//public interface IModelStateErrorHandler
10+
//{
11+
// /// <summary>
12+
// /// Adds API validation errors to the model state with proper field mapping
13+
// /// </summary>
14+
// /// <param name="modelState">The model state to add errors to</param>
15+
// /// <param name="apiError">The parsed API error response</param>
16+
// /// <param name="fieldMappings">Optional mapping of API field names to model property names</param>
17+
// void AddApiErrorsToModelState(ModelStateDictionary modelState, ApiErrorResponse apiError,
18+
// Dictionary<string, string>? fieldMappings = null);
1919

20-
/// <summary>
21-
/// Adds a general error message to the model state
22-
/// </summary>
23-
/// <param name="modelState">The model state to add the error to</param>
24-
/// <param name="errorMessage">The error message to add</param>
25-
void AddGeneralError(ModelStateDictionary modelState, string errorMessage);
26-
}
20+
// /// <summary>
21+
// /// Adds a general error message to the model state
22+
// /// </summary>
23+
// /// <param name="modelState">The model state to add the error to</param>
24+
// /// <param name="errorMessage">The error message to add</param>
25+
// void AddGeneralError(ModelStateDictionary modelState, string errorMessage);
26+
//}

src/DfE.ExternalApplications.Domain/DfE.ExternalApplications.Domain.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="DfE.CoreLibs.Contracts" Version="1.0.36" />
10+
<PackageReference Include="DfE.CoreLibs.Contracts" Version="1.0.42" />
1111
</ItemGroup>
1212

1313
</Project>

src/DfE.ExternalApplications.Infrastructure/DfE.ExternalApplications.Infrastructure.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
<ItemGroup>
1010
<PackageReference Include="DfE.CoreLibs.Caching" Version="1.0.10" />
11-
<PackageReference Include="DfE.CoreLibs.Contracts" Version="1.0.36" />
12-
<PackageReference Include="GovUK.Dfe.ExternalApplications.Api.Client" Version="0.1.15" />
1311
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.3.0" />
1412
</ItemGroup>
1513

src/DfE.ExternalApplications.Infrastructure/Services/ApiErrorParser.cs

Lines changed: 0 additions & 187 deletions
This file was deleted.

src/DfE.ExternalApplications.Infrastructure/Services/ModelStateErrorHandler.cs

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/DfE.ExternalApplications.Web/DfE.ExternalApplications.Web.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="DfE.CoreLibs.Caching" Version="1.0.10" />
12-
<PackageReference Include="DfE.CoreLibs.Contracts" Version="1.0.36" />
13-
<PackageReference Include="GovUK.Dfe.ExternalApplications.Api.Client" Version="0.1.15" />
1412
<PackageReference Include="GovUk.Frontend.AspNetCore" Version="3.2.2" />
1513
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
16-
<PackageReference Include="DfE.CoreLibs.Security" Version="1.1.13" />
14+
<PackageReference Include="DfE.CoreLibs.Security" Version="1.1.14" />
1715
</ItemGroup>
1816

1917
<ItemGroup>

0 commit comments

Comments
 (0)