In JAVA, we have different exceptions. We can catch them with a try/catch. But what if we forget or we don’t want to put a try/catch block in the code, how to catch it with Sentry ? What if we don’t know that a part of the code have a risk to have an exception ?
It seems that sentry or sentry-spring don’t handle basic JAVA exception (or I don’t know how…) without a try/catch block.
Example :
We write this part of code and do the different configuration for having Sentry in our application :
public static void main(String args) {
double value = 1 / 0;
}
If you run this part of code, Sentry will not send an error but, we can see it on the Console.
So, if I understand what you said, Sentry could handle all errors by JAVA by using UncaughtException handler.
Another example that would help you to understand what I mean :
You have a RestController and you make a request on an endpoint. On this endpoint, you forget to put anything to catch the error, or don’t want to do that, or you don’t know that an error will be raised.
@RestController(value="/test")
public class TestRestController { @GetMapping
public void get() {
…
// Here you have an error like java.lang.ArithmeticException, NPE or other
…
}
}
In regards to Spring MVC integration, we have SentryExceptionResolver that catches unhandled exceptions that are thrown during request processing. If you use Spring Boot, it gets autoconfigured and works out of the box. Take a look at docs