Skip to content

Commit

Permalink
[FEAT] INTERNAL SERVER ERROR handle 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
sung-silver committed Jan 17, 2025
1 parent 11a270c commit 0d73206
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package sopt.makers.authentication.support.code.support.failure;

import static lombok.AccessLevel.PRIVATE;

import sopt.makers.authentication.support.code.base.*;

import org.springframework.http.*;

import lombok.*;

@Getter
@RequiredArgsConstructor(access = PRIVATE)
public enum CommonFailure implements FailureCode {
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버 내부 오류입니다");
private final HttpStatus status;
private final String message;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package sopt.makers.authentication.support.exception;

import static sopt.makers.authentication.support.code.support.failure.CommonFailure.INTERNAL_SERVER_ERROR;

import sopt.makers.authentication.support.common.api.BaseResponse;
import sopt.makers.authentication.support.exception.domain.AuthException;

import org.springframework.http.ResponseEntity;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

Expand All @@ -12,9 +14,15 @@
@Slf4j
@RestControllerAdvice
public class ApplicationExceptionHandler {
@ExceptionHandler(RuntimeException.class)
ResponseEntity<BaseResponse<?>> handleInternalException(final RuntimeException e) {
log.error(e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(BaseResponse.ofFailure(INTERNAL_SERVER_ERROR));
}

@ExceptionHandler(AuthException.class)
ResponseEntity<BaseResponse<?>> authFailureException(final AuthException e) {
ResponseEntity<BaseResponse<?>> handleAuthException(final AuthException e) {
log.error(e.getError().getMessage());
return ResponseEntity.status(e.getError().getStatus().value())
.body(BaseResponse.ofFailure(e.getError()));
Expand Down

0 comments on commit 0d73206

Please sign in to comment.