+ 4
Why should your code typically not catch exceptions of type Error?
3 Respuestas
+ 4
The Error and Exception classes are both subclasses of the Throwable class.
Exceptions are some unforeseen conditions that arise during program execution and it is a good idea to handle them in the code.
However, an Error, indicates a serious problem in the code that must be resolved.
It is a bad idea to catch an Error like we catch exceptions using the try-catch block. And anyways, we can't do much about an error since most of them are related to the JVM itself that is responsible for running the program.
The best example is the OutOfMemoryError, the application cannot recover in any way if the JVM is out of memory.
+ 2
You catch them cause if you don't the program crashes/stops running
So I guess if you don't care about that, sure don't catch them. That could typically only be for a project that needs debugging, never for a final product.
0
Sssss