Skip to content

Commit a9c5822

Browse files
authored
Chore: ExceptionHandler 추가 (#312)
1 parent cb3bc27 commit a9c5822

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

back/src/main/java/com/back/global/globalExceptionHandler/GlobalExceptionHandler.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import com.back.global.exception.ServiceException;
44
import com.back.global.rsData.RsData;
5+
import io.sentry.Sentry;
56
import jakarta.validation.ConstraintViolationException;
67
import lombok.RequiredArgsConstructor;
8+
import lombok.extern.slf4j.Slf4j;
79
import org.springframework.http.ResponseEntity;
810
import org.springframework.http.converter.HttpMessageNotReadableException;
911
import org.springframework.security.authorization.AuthorizationDeniedException;
@@ -20,6 +22,7 @@
2022

2123
import static org.springframework.http.HttpStatus.*;
2224

25+
@Slf4j
2326
@RestControllerAdvice
2427
@RequiredArgsConstructor
2528
public class GlobalExceptionHandler {
@@ -131,4 +134,18 @@ public ResponseEntity<RsData<Void>> handle(ServiceException ex) {
131134
.getStatusCode()
132135
);
133136
}
137+
138+
@ExceptionHandler(Exception.class)
139+
public ResponseEntity<RsData<Void>> handle(Exception ex) {
140+
log.error("Unhandled exception occurred", ex);
141+
Sentry.captureException(ex);
142+
143+
return new ResponseEntity<>(
144+
new RsData<>(
145+
"500-1",
146+
"서버 오류가 발생했습니다."
147+
),
148+
INTERNAL_SERVER_ERROR
149+
);
150+
}
134151
}

0 commit comments

Comments
 (0)