Skip to content

Update GlobalExceptionHandler.java #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
@Slf4j
public class GlobalExceptionHandler {


// @ExceptionHandler(HttpClientErrorException.class)
// @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
// public ErrorResponse httpClientErrorHandler(HttpClientErrorException httpClientErrorException) {
// log.info(httpClientErrorException.getMessage());
// return new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), httpClientErrorException.getMessage());
// }


@ExceptionHandler({BadRequestException.class, NoSuchFieldException.class, NumberFormatException.class, JsonProcessingException.class, IllegalArgumentException.class, PropertyReferenceException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorResponse runtime(RuntimeException exception) {
Expand All @@ -34,14 +43,3 @@ public ErrorResponse notFoundHandler(NotFoundException notFoundException) {
@ExceptionHandler(ConflictException.class)
@ResponseStatus(HttpStatus.CONFLICT)
public ErrorResponse conflictHandler(ConflictException conflictException) {
log.info(conflictException.getMessage());
return new ErrorResponse(HttpStatus.CONFLICT.value(), conflictException.getMessage());
}

@ExceptionHandler(HttpClientErrorException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ErrorResponse httpClientErrorHandler(HttpClientErrorException httpClientErrorException) {
log.info(httpClientErrorException.getMessage());
return new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), httpClientErrorException.getMessage());
}
}