Acert imports authservice
This commit is contained in:
parent
b490b04bd1
commit
fd5f456a31
2 changed files with 8 additions and 19 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package br.com.rayankonecny.authserviceapi.controllers.exceptions;
|
||||
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.validation.FieldError;
|
||||
|
|
@ -23,30 +22,21 @@ import java.util.ArrayList;
|
|||
public class ControllerExceptionHandler {
|
||||
|
||||
@ExceptionHandler(UsernameNotFoundException.class)
|
||||
ResponseEntity<StandardError> handleNotFoundException(final UsernameNotFoundException ex, final HttpServletRequest request) {
|
||||
ResponseEntity<StandardError> handleNotFoundException(final UsernameNotFoundException ex,
|
||||
final HttpServletRequest request) {
|
||||
|
||||
return ResponseEntity.status(NOT_FOUND).body(
|
||||
|
||||
StandardError.builder()
|
||||
.timestamp(now())
|
||||
.status(NOT_FOUND.value())
|
||||
.error(NOT_FOUND.getReasonPhrase())
|
||||
.message(ex.getMessage())
|
||||
.path(request.getRequestURI())
|
||||
.build());
|
||||
StandardError.builder().timestamp(now()).status(NOT_FOUND.value()).error(NOT_FOUND.getReasonPhrase())
|
||||
.message(ex.getMessage()).path(request.getRequestURI()).build());
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
ResponseEntity<StandardError> handleMethodArgumentNotValidException(final MethodArgumentNotValidException ex, final HttpServletRequest request) {
|
||||
ResponseEntity<StandardError> handleMethodArgumentNotValidException(final MethodArgumentNotValidException ex,
|
||||
final HttpServletRequest request) {
|
||||
|
||||
var error = ValidationException.builder()
|
||||
.timestamp(now())
|
||||
.status(BAD_REQUEST.value())
|
||||
.error("Validation Exception")
|
||||
.message("Exception in validation attributes")
|
||||
.path(request.getRequestURI())
|
||||
.errors(new ArrayList<>())
|
||||
.build();
|
||||
var error = ValidationException.builder().timestamp(now()).status(BAD_REQUEST.value()).error("Validation Exception")
|
||||
.message("Exception in validation attributes").path(request.getRequestURI()).errors(new ArrayList<>()).build();
|
||||
|
||||
for (FieldError fieldError : ex.getBindingResult().getFieldErrors()) {
|
||||
error.addError(fieldError.getField(), fieldError.getDefaultMessage());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package br.com.rayankonecny.authserviceapi.models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue