diff --git a/src/main/java/com/example/nto/domain/exception/advice/GlobalExceptionalHandler.java b/src/main/java/com/example/nto/domain/exception/advice/GlobalExceptionalHandler.java index cbe6965..b3b167d 100644 --- a/src/main/java/com/example/nto/domain/exception/advice/GlobalExceptionalHandler.java +++ b/src/main/java/com/example/nto/domain/exception/advice/GlobalExceptionalHandler.java @@ -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 handlerSomethingWentWrongException(SomethingWentWrongException e) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } + + @ExceptionHandler(AccessDeniedException.class) + public ResponseEntity handlerAccessDeniedException(AccessDeniedException e) { + return new ResponseEntity<>(e.getMessage(), HttpStatus.UNAUTHORIZED); + } + + @ExceptionHandler(ResourceNotFoundException.class) + public ResponseEntity handlerAccessDeniedException(ResourceNotFoundException e) { + return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND); + } + + @ExceptionHandler(ConflictResourceException.class) + public ResponseEntity handlerConflictResourceException(ConflictResourceException e) { + return new ResponseEntity<>(e.getMessage(), HttpStatus.CONFLICT); + } + + @ExceptionHandler(ImageUploadException.class) + public ResponseEntity handlerImageUploadException(ImageUploadException e) { + return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(ImageSendException.class) + public ResponseEntity handlerImageSendException(ImageSendException e) { + return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(ConstraintViolationException.class) + public ResponseEntity handlerConstraintViolationException(ConstraintViolationException e) { + return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST); + } } + +