NCP-3 add usercontent crud's,dto,exception and start restcontroller
This commit is contained in:
@@ -8,6 +8,7 @@ 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.exception.ContentNotFoundException;
|
||||
import ru.soune.no_copy.exception.NotValidationPasswordException;
|
||||
import ru.soune.no_copy.exception.UserAlreadyExistsException;
|
||||
import ru.soune.no_copy.exception.UserNotFoundException;
|
||||
@@ -53,6 +54,17 @@ public class GlobalExceptionHandler {
|
||||
));
|
||||
}
|
||||
|
||||
@ExceptionHandler(ContentNotFoundException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public ResponseEntity<?> handleUserNotFoundException(ContentNotFoundException ex) {
|
||||
return ResponseEntity.
|
||||
badRequest()
|
||||
.body(Map.of(
|
||||
"success", false,
|
||||
"message" ,ex.getMessage()
|
||||
));
|
||||
}
|
||||
|
||||
@ExceptionHandler(NotValidationPasswordException.class)
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public ResponseEntity<?> handleNotValidationPasswordException(NotValidationPasswordException ex) {
|
||||
|
||||
Reference in New Issue
Block a user