FAQ 26.01 What belongs in a try block?Code that may throw an exception from which this function might be able to recover. If the code called from a try block cannot throw an exception, then there is no need for the try block. Similarly, if the code called from a try block can throw exceptions but this function cannot recover from the exceptions, then there is no point in catching the exception and no point in putting the code in a try block. Simply put, a function shouldn't worry about things that it can't fix. The important message here is that try…catch is not like old-fashioned error codes. Programmers who don't realize the differences put a try block around every call to every routine that could throw an exception. This is not wise. |