Roland suspects that a block of code he has written could generate a bunch of exceptions, and he just doesn’t want to deal with it. Here is how he ended up handling it. What does this do? Is it a good idea?
```
try {
// lots of lines of code
}
catch ( Exception e )
{
// do nothing
}
```
This will catch all exceptions of type Exception or any of its descendants. It will not catch exceptions descending from Error, but since these are generally catastrophic (out of memory, JVM error, etc.), there isn’t much a program to do to recover anyway.
The bigger problem is that the catch clause does nothing at all, so the program will continue to execute without having done anything to resolve the problem that generated the exception. It is quite likely that a problem will crop up later and it may be difficult to trace the problem back to its origin in the try block. Since Roland is using Exception as a catch-all (a little joke there), he can’t do anything specific to recover, but he could at least produce a stack trace so the user knows there is a problem and what kind of problem it is.
You might also like to view...
A(n) ________ refers to a cell by its fixed position in a worksheet; the reference will NOT change when copied and pasted
Fill in the blank(s) with correct word
What happens each time you open an attachment file in Access?
A) Access creates a temporary file on your computer's hard drive. B) The attachment opens in Design view. C) The attachment opens in a form or report. D) The attachment opens as a hyperlink.