Home >Java >javaTutorial >Rethrowing an exception
An exception caught by a catch block can be rethrown to be caught by an external catch.
Rethrow allows multiple handlers to access the exception.
One handler may manage one aspect of the exception, while another handler handles another aspect.
When rethrowing the exception, it is not recaptured by the same catch, but will be propagated to the next catch block.
Division by zero errors are handled locally in the genException() method.
Array limit errors are re-thrown and caught in the main() method.
The above is the detailed content of Rethrowing an exception. For more information, please follow other related articles on the PHP Chinese website!