|
3 | 3 | using PoZiomkaDomain.Admin.Exceptions; |
4 | 4 | using PoZiomkaDomain.Application.Exceptions; |
5 | 5 | using PoZiomkaDomain.Common.Exceptions; |
| 6 | +using PoZiomkaDomain.Communication.Exceptions; |
6 | 7 | using PoZiomkaDomain.Exceptions; |
7 | 8 | using PoZiomkaDomain.Form.Exceptions; |
| 9 | +using PoZiomkaDomain.Reservation.Exceptions; |
8 | 10 | using PoZiomkaDomain.Room.Exceptions; |
9 | 11 | using PoZiomkaDomain.Student.Exceptions; |
10 | 12 | using PoZiomkaDomain.StudentAnswers.Exceptions; |
11 | 13 | using PoZiomkaInfrastructure.Exceptions; |
| 14 | +using System; |
12 | 15 | using System.Text.Json; |
13 | 16 |
|
14 | 17 | namespace PoZiomkaApi; |
@@ -232,6 +235,36 @@ public async Task Invoke(HttpContext context) |
232 | 235 | Title = "User can't fill forms" |
233 | 236 | }; |
234 | 237 | } |
| 238 | + catch (CommunicationNotFoundException exception) |
| 239 | + { |
| 240 | + context.Response.StatusCode = StatusCodes.Status404NotFound; |
| 241 | + problemDetails = new ProblemDetails() |
| 242 | + { |
| 243 | + Status = StatusCodes.Status404NotFound, |
| 244 | + Detail = exception.Message, |
| 245 | + Title = "Communication not found" |
| 246 | + }; |
| 247 | + } |
| 248 | + catch (UnauthorizedDeleteException exception) |
| 249 | + { |
| 250 | + context.Response.StatusCode = StatusCodes.Status404NotFound; |
| 251 | + problemDetails = new ProblemDetails() |
| 252 | + { |
| 253 | + Status = StatusCodes.Status401Unauthorized, |
| 254 | + Detail = exception.Message, |
| 255 | + Title = "User not authorized to delete this notification" |
| 256 | + }; |
| 257 | + } |
| 258 | + catch (ReservationNotFoundException exception) |
| 259 | + { |
| 260 | + context.Response.StatusCode = StatusCodes.Status404NotFound; |
| 261 | + problemDetails = new ProblemDetails() |
| 262 | + { |
| 263 | + Status = StatusCodes.Status404NotFound, |
| 264 | + Detail = exception.Message, |
| 265 | + Title = "Reservation not found" |
| 266 | + }; |
| 267 | + } |
235 | 268 | catch (DomainException exception) |
236 | 269 | { |
237 | 270 | context.Response.StatusCode = StatusCodes.Status500InternalServerError; |
|
0 commit comments