Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:woowacourse-teams/2023-votogether in…
Browse files Browse the repository at this point in the history
…to feat/#95
  • Loading branch information
tjdtls690 committed Jul 20, 2023
2 parents e65bfab + 1c3200b commit 1d93dd7
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
package com.votogether.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

@ExceptionHandler
public ResponseEntity<ExceptionResponse> handleException(final Exception e) {
log.error("[" + e.getClass() + "] : " + e.getMessage());
return ResponseEntity.internalServerError()
.body(new ExceptionResponse(-9999, "알 수 없는 서버 에러가 발생했습니다."));
}

@ExceptionHandler
public ResponseEntity<ExceptionResponse> handleBadRequestException(final BadRequestException e) {
log.warn("[" + e.getClass() + "] : " + e.getMessage());
return ResponseEntity.badRequest()
.body(ExceptionResponse.from(e));
}

@ExceptionHandler
public ResponseEntity<ExceptionResponse> handleNotFoundException(final NotFoundException e) {
log.warn("[" + e.getClass() + "] : " + e.getMessage());
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(ExceptionResponse.from(e));
}
Expand Down

0 comments on commit 1d93dd7

Please sign in to comment.