You need to wrap the function call(s) that may throw an exception in a try...catch block.
class EvilException extends Exception {}
class BadException extends Exception {}
function someMethodThatMayThrowException() {
...
...
throw new EvilException( "I am an evil exception. HAHAHAHA" );
}
try {
someMethodThatMayThrowException();
} catch( BadException $e ) {
//deal with BadException here...
} catch( EvilException $e ) {
//deal with EvilException here...
throw new Exception( "will be caught in next catch block" );
} catch( Exception $e ) {
echo $e->getMessage(); //echoes the string: "will be caught in next catch block"
}
If you catch the exception(s), the script will not terminate. If a thrown exception does not have a catch block to jump into, the aforementioned will happen.