API: Capture unhandled exceptions with Sentry

This commit is contained in:
Braydon 2024-04-27 03:19:43 -04:00
parent 855b040e8f
commit 526d68763f

View File

@ -24,6 +24,7 @@
package cc.restfulmc.api.exception;
import cc.restfulmc.api.model.response.ErrorResponse;
import io.sentry.Sentry;
import lombok.NonNull;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -66,6 +67,7 @@ public final class ExceptionControllerAdvice {
}
if (status == null) { // Fallback to 500
status = HttpStatus.INTERNAL_SERVER_ERROR;
Sentry.captureException(ex); // Capture with Sentry
}
return new ResponseEntity<>(new ErrorResponse(status, message), status);
}