diff --git a/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/exceptions/ControllerExceptionHandler.java b/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/exceptions/ControllerExceptionHandler.java index f67b89f..81ad5a1 100644 --- a/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/exceptions/ControllerExceptionHandler.java +++ b/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/exceptions/ControllerExceptionHandler.java @@ -10,11 +10,13 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import jakarta.servlet.http.HttpServletRequest; import br.com.rayankonecny.hdcommoslib.models.exceptions.ValidationException; +import br.com.rayankonecny.hdcommoslib.models.exceptions.RefreshTokenExpired; import br.com.rayankonecny.hdcommoslib.models.exceptions.StandardError; import static java.time.LocalDateTime.now; import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.NOT_FOUND; +import static org.springframework.http.HttpStatus.NOT_ACCEPTABLE; import java.util.ArrayList; @@ -44,4 +46,16 @@ public class ControllerExceptionHandler { return ResponseEntity.badRequest().body(error); } + + @ExceptionHandler(RefreshTokenExpired.class) + ResponseEntity handleRefreshTokenExpired(final RefreshTokenExpired ex, + final HttpServletRequest request) { + + var error = ValidationException.builder().timestamp(now()).status(NOT_ACCEPTABLE.value()) + .error("Validation Exception").message("Refresh Token Expired").path(request.getRequestURI()) + .errors(new ArrayList<>()).build(); + + return ResponseEntity.badRequest().body(error); + } + } diff --git a/rest.http b/rest.http index 4c07543..1f96965 100644 --- a/rest.http +++ b/rest.http @@ -54,4 +54,4 @@ Accept: application/json { "refreshToken": "8e7d2ada-7fcd-4b0d-92f0-55b5d8e6fc87" -} \ No newline at end of file +}