develop #3

Merged
Petr merged 18 commits from develop into master 2025-02-19 12:37:36 +00:00
Showing only changes of commit be035d4a82 - Show all commits

View File

@ -1,8 +1,7 @@
package com.example.nto.domain.exception.advice; package com.example.nto.domain.exception.advice;
import com.example.nto.domain.exception.CodeNotFoundException; import com.amazonaws.services.organizations.model.ConstraintViolationException;
import com.example.nto.domain.exception.EmployeeNotFoundException; import com.example.nto.domain.exception.*;
import com.example.nto.domain.exception.SomethingWentWrongException;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
@ -27,4 +26,36 @@ public class GlobalExceptionalHandler {
public ResponseEntity<HttpStatus> handlerSomethingWentWrongException(SomethingWentWrongException e) { public ResponseEntity<HttpStatus> handlerSomethingWentWrongException(SomethingWentWrongException e) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); 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);
}
}