feat: fix GlobalExceptionalHandler
This commit is contained in:
parent
3070441490
commit
be035d4a82
@ -1,8 +1,7 @@
|
||||
package com.example.nto.domain.exception.advice;
|
||||
|
||||
import com.example.nto.domain.exception.CodeNotFoundException;
|
||||
import com.example.nto.domain.exception.EmployeeNotFoundException;
|
||||
import com.example.nto.domain.exception.SomethingWentWrongException;
|
||||
import com.amazonaws.services.organizations.model.ConstraintViolationException;
|
||||
import com.example.nto.domain.exception.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
@ -27,4 +26,36 @@ public class GlobalExceptionalHandler {
|
||||
public ResponseEntity<HttpStatus> handlerSomethingWentWrongException(SomethingWentWrongException e) {
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
public ResponseEntity<String> handlerAccessDeniedException(AccessDeniedException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@ExceptionHandler(ResourceNotFoundException.class)
|
||||
public ResponseEntity<String> handlerAccessDeniedException(ResourceNotFoundException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@ExceptionHandler(ConflictResourceException.class)
|
||||
public ResponseEntity<String> handlerConflictResourceException(ConflictResourceException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
@ExceptionHandler(ImageUploadException.class)
|
||||
public ResponseEntity<String> handlerImageUploadException(ImageUploadException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(ImageSendException.class)
|
||||
public ResponseEntity<String> handlerImageSendException(ImageSendException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
public ResponseEntity<String> handlerConstraintViolationException(ConstraintViolationException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user