File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
back/src/main/java/com/back/global/globalExceptionHandler Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 22
33import com .back .global .exception .ServiceException ;
44import com .back .global .rsData .RsData ;
5+ import io .sentry .Sentry ;
56import jakarta .validation .ConstraintViolationException ;
67import lombok .RequiredArgsConstructor ;
8+ import lombok .extern .slf4j .Slf4j ;
79import org .springframework .http .ResponseEntity ;
810import org .springframework .http .converter .HttpMessageNotReadableException ;
911import org .springframework .security .authorization .AuthorizationDeniedException ;
2022
2123import static org .springframework .http .HttpStatus .*;
2224
25+ @ Slf4j
2326@ RestControllerAdvice
2427@ RequiredArgsConstructor
2528public 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}
You can’t perform that action at this time.
0 commit comments