This commit is contained in:
@@ -8,8 +8,10 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import ru.soune.no_copy.dto.MessageCode;
|
||||
import ru.soune.no_copy.exception.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
@RestControllerAdvice
|
||||
@@ -30,14 +32,15 @@ public class GlobalExceptionHandler {
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserAlreadyExistsException.class)
|
||||
@ResponseStatus(HttpStatus.CONFLICT)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<?> handleUserContainsException(UserAlreadyExistsException ex) {
|
||||
return ResponseEntity.
|
||||
badRequest()
|
||||
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.body(Map.of(
|
||||
"success", false,
|
||||
"message" ,ex.getMessage()
|
||||
));
|
||||
"msg_id", ex.getMessageId(),
|
||||
"message_code", ex.getMessageCode(),
|
||||
"message_desc", ex.getMessageDescription()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserNotFoundException.class)
|
||||
|
||||
Reference in New Issue
Block a user