|
|
@@ -1,5 +1,6 @@
|
|
|
package com.danielbohry.authservice.api;
|
|
|
|
|
|
+import com.danielbohry.authservice.exceptions.BadRequestException;
|
|
|
import com.danielbohry.authservice.exceptions.NotFoundException;
|
|
|
import io.jsonwebtoken.ExpiredJwtException;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
@@ -34,6 +35,15 @@ public class ControllerAdvisor extends ResponseEntityExceptionHandler {
|
|
|
return new ResponseEntity<>(body, HttpStatus.BAD_REQUEST);
|
|
|
}
|
|
|
|
|
|
+ @ExceptionHandler(BadRequestException.class)
|
|
|
+ protected ResponseEntity<Object> handleBadRequestException(RuntimeException ex) {
|
|
|
+ Map<String, Object> body = new LinkedHashMap<>();
|
|
|
+ body.put("timestamp", LocalDateTime.now());
|
|
|
+ body.put("message", ex.getMessage());
|
|
|
+
|
|
|
+ return new ResponseEntity<>(body, HttpStatus.BAD_REQUEST);
|
|
|
+ }
|
|
|
+
|
|
|
@ExceptionHandler(ExpiredJwtException.class)
|
|
|
protected ResponseEntity<Object> handleExpiredJwtException(RuntimeException ex) {
|
|
|
Map<String, Object> body = new LinkedHashMap<>();
|