|
10 | 10 | using ResponseCrafter.Extensions; |
11 | 11 | using ResponseCrafter.HttpExceptions; |
12 | 12 | using ResponseCrafter.Options; |
13 | | -using ServiceResponseCrafter.Dtos; |
14 | | -using ServiceResponseCrafter.ExceptionHandler; |
15 | 13 | using static ResponseCrafter.Helpers.ExceptionMessageBuilder; |
16 | 14 | using IExceptionHandler = Microsoft.AspNetCore.Diagnostics.IExceptionHandler; |
17 | 15 |
|
@@ -56,9 +54,6 @@ public async ValueTask<bool> TryHandleAsync(HttpContext httpContext, |
56 | 54 | case ImportException targetInvocationException: |
57 | 55 | await HandleImportExceptionAsync(httpContext, targetInvocationException, cancellationToken); |
58 | 56 | break; |
59 | | - case ServiceException serviceException: |
60 | | - await HandleServiceExceptionAsync(httpContext, serviceException, cancellationToken); |
61 | | - break; |
62 | 57 | case GridifyException gridifyException: |
63 | 58 | await HandleGridifyExceptionAsync(httpContext, gridifyException, cancellationToken); |
64 | 59 | break; |
@@ -102,42 +97,6 @@ private async Task HandleImportExceptionAsync(HttpContext httpContext, |
102 | 97 | } |
103 | 98 | } |
104 | 99 |
|
105 | | - private async Task HandleServiceExceptionAsync(HttpContext httpContext, |
106 | | - ServiceException serviceException, |
107 | | - CancellationToken cancellationToken) |
108 | | - { |
109 | | - var originalMessage = serviceException.Message.ConvertCase(_convention); |
110 | | - |
111 | | - var response = new ServiceResponse |
112 | | - { |
113 | | - Message = originalMessage, |
114 | | - ResponseStatus = serviceException.ResponseStatus, |
115 | | - Success = false |
116 | | - }; |
117 | | - |
118 | | - httpContext.Response.StatusCode = (int)serviceException.ResponseStatus; |
119 | | - |
120 | | - if (_visibility == "Public") |
121 | | - { |
122 | | - if (httpContext.Response.StatusCode >= 500) |
123 | | - { |
124 | | - response.Message = DefaultMessage.ConvertCase(_convention); |
125 | | - } |
126 | | - } |
127 | | - |
128 | | - |
129 | | - if (httpContext.Response.StatusCode >= 500) |
130 | | - { |
131 | | - _logger.LogError("ServiceException encountered: {ExceptionMessage}", originalMessage); |
132 | | - } |
133 | | - else |
134 | | - { |
135 | | - _logger.LogWarning("ServiceException encountered: {ExceptionMessage}", originalMessage); |
136 | | - } |
137 | | - |
138 | | - await httpContext.Response.WriteAsJsonAsync(response, cancellationToken); |
139 | | - } |
140 | | - |
141 | 100 |
|
142 | 101 | private async Task HandleGridifyExceptionAsync(HttpContext httpContext, |
143 | 102 | GridifyException gridifyException, |
|
0 commit comments