<<< Throwing and re-throwing an exception | Index | throws declaration >>> |
Syntax:
throw exceptionReference; // rethrow throw new anotherException( parameters ); // create and throw new exception
Rethrowing is useful when:
catch block catches exception but is unable to handle it
catch block decides that exception should be handled by the calling environment
throw allows programmer to
provide exception-handling code in one place where it's the most appropriate
<<< Throwing and re-throwing an exception | Index | throws declaration >>> |