Fix imports
This commit is contained in:
parent
ff96ecf8a1
commit
239850a2fc
1 changed files with 6 additions and 25 deletions
|
|
@ -13,40 +13,21 @@ import br.com.rayankonecny.hdcommoslib.models.exceptions.StandardError;
|
|||
import br.com.rayankonecny.hdcommoslib.models.exceptions.ValidationException;
|
||||
|
||||
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.BAD_REQUEST;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@ControllerAdvice
|
||||
public class ControllerExceptionHandler {
|
||||
|
||||
// @ExceptionHandler(UsernameNotFoundException.class)
|
||||
// ResponseEntity<StandardError> handleNotAuthorizedException(final UsernameNotFoundException ex,final HttpServletRequest request) {
|
||||
@ExceptionHandler({ BadCredentialsException.class, RefreshTokenExpired.class, UsernameNotFoundException.class })
|
||||
ResponseEntity<StandardError> handleBadCredentialsException(final RuntimeException 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})
|
||||
ResponseEntity<StandardError> handleBadCredentialsException(final RuntimeException 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());
|
||||
return ResponseEntity.status(UNAUTHORIZED)
|
||||
.body(StandardError.builder().timestamp(now()).status(UNAUTHORIZED.value())
|
||||
.error(UNAUTHORIZED.getReasonPhrase()).message(ex.getMessage()).path(request.getRequestURI()).build());
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue