Skip to content
Merged
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 @@ -2,8 +2,10 @@

import com.back.global.exception.ServiceException;
import com.back.global.rsData.RsData;
import io.sentry.Sentry;
import jakarta.validation.ConstraintViolationException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.security.authorization.AuthorizationDeniedException;
Expand All @@ -20,6 +22,7 @@

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

@Slf4j
@RestControllerAdvice
@RequiredArgsConstructor
public class GlobalExceptionHandler {
Expand Down Expand Up @@ -131,4 +134,18 @@ public ResponseEntity<RsData<Void>> handle(ServiceException ex) {
.getStatusCode()
);
}

@ExceptionHandler(Exception.class)
public ResponseEntity<RsData<Void>> handle(Exception ex) {
log.error("Unhandled exception occurred", ex);
Sentry.captureException(ex);

return new ResponseEntity<>(
new RsData<>(
"500-1",
"서버 오류가 발생했습니다."
),
INTERNAL_SERVER_ERROR
);
}
}