Fix imports

This commit is contained in:
rayankonecny 2025-12-18 04:57:11 +00:00
parent ff96ecf8a1
commit 239850a2fc

View file

@ -13,40 +13,21 @@ import br.com.rayankonecny.hdcommoslib.models.exceptions.StandardError;
import br.com.rayankonecny.hdcommoslib.models.exceptions.ValidationException; import br.com.rayankonecny.hdcommoslib.models.exceptions.ValidationException;
import static java.time.LocalDateTime.now; import static java.time.LocalDateTime.now;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.UNAUTHORIZED; import static org.springframework.http.HttpStatus.UNAUTHORIZED;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
import java.util.ArrayList; import java.util.ArrayList;
@ControllerAdvice @ControllerAdvice
public class ControllerExceptionHandler { public class ControllerExceptionHandler {
// @ExceptionHandler(UsernameNotFoundException.class)
// ResponseEntity<StandardError> handleNotAuthorizedException(final UsernameNotFoundException ex,final HttpServletRequest request) {
// return ResponseEntity.status(UNAUTHORIZED).body(
// StandardError.builder()
// .timestamp(now())
// .status(UNAUTHORIZED.value())
// .error(UNAUTHORIZED.getReasonPhrase())
// .message(ex.getMessage())
// .path(request.getRequestURI())
// .build());
// }
@ExceptionHandler({ BadCredentialsException.class, RefreshTokenExpired.class, UsernameNotFoundException.class }) @ExceptionHandler({ BadCredentialsException.class, RefreshTokenExpired.class, UsernameNotFoundException.class })
ResponseEntity<StandardError> handleBadCredentialsException(final RuntimeException ex, final HttpServletRequest request) { ResponseEntity<StandardError> handleBadCredentialsException(final RuntimeException ex,
final HttpServletRequest request) {
return ResponseEntity.status(UNAUTHORIZED).body( return ResponseEntity.status(UNAUTHORIZED)
StandardError.builder() .body(StandardError.builder().timestamp(now()).status(UNAUTHORIZED.value())
.timestamp(now()) .error(UNAUTHORIZED.getReasonPhrase()).message(ex.getMessage()).path(request.getRequestURI()).build());
.status(UNAUTHORIZED.value())
.error(UNAUTHORIZED.getReasonPhrase())
.message(ex.getMessage())
.path(request.getRequestURI())
.build());
} }
@ExceptionHandler(MethodArgumentNotValidException.class) @ExceptionHandler(MethodArgumentNotValidException.class)