diff --git a/AutobusApi.Api/Middlewares/GlobalExceptionHandlerMiddleware.cs b/AutobusApi.Api/Middlewares/GlobalExceptionHandlerMiddleware.cs index 9fb9d22..0ea37cc 100644 --- a/AutobusApi.Api/Middlewares/GlobalExceptionHandlerMiddleware.cs +++ b/AutobusApi.Api/Middlewares/GlobalExceptionHandlerMiddleware.cs @@ -17,6 +17,7 @@ public class GlobalExceptionHandlerMiddleware : IMiddleware { typeof(LoginException), HandleLoginException }, { typeof(RenewAccessTokenException), HandleRenewAccessTokenException }, { typeof(RevokeRefreshTokenException), HandleRevokeRefreshTokenException }, + { typeof(NotFoundException), HandleNotFoundException }, }; } @@ -111,6 +112,20 @@ public class GlobalExceptionHandlerMiddleware : IMiddleware }); } + private async Task HandleNotFoundException(HttpContext context, Exception exception) + { + context.Response.StatusCode = StatusCodes.Status404NotFound; + context.Response.ContentType = "application/problem+json"; + + await context.Response.WriteAsJsonAsync(new ProblemDetails() + { + Status = StatusCodes.Status404NotFound, + Type = "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4", + // Title = "Refresh token revocation failed.", + // Detail = "Check validity of your refresh token." + }); + } + private async Task HandleUnhandledExceptionException(HttpContext context, Exception exception) { context.Response.StatusCode = StatusCodes.Status500InternalServerError; diff --git a/AutobusApi.Application/RouteSearch/RouteSearchQueryHandler.cs b/AutobusApi.Application/RouteSearch/RouteSearchQueryHandler.cs index e7e8941..2532cea 100644 --- a/AutobusApi.Application/RouteSearch/RouteSearchQueryHandler.cs +++ b/AutobusApi.Application/RouteSearch/RouteSearchQueryHandler.cs @@ -34,6 +34,11 @@ public class RouteSearchQueryHandler : IRequestHandler(_mapper.ConfigurationProvider).ToList(); } @@ -76,13 +81,6 @@ public class RouteSearchQueryHandler : IRequestHandler(previousVertex, currentVertex)); - var vertexFromDifferentRoute = graph.Vertices.FirstOrDefault(v => v.Address.Id == currentVertex.Address.Id); - - if (vertexFromDifferentRoute != null) - { - graph.AddEdge(new SEquatableEdge(currentVertex, vertexFromDifferentRoute)); - } - previousVertex = currentVertex; } } @@ -111,7 +109,10 @@ public class RouteSearchQueryHandler : IRequestHandler