getPrevious
If this exception is triggered by another exception, this method returns the previous exception. If not, return null.
If the exception is triggered by another exception, getPrevious()
method will return another exception. Otherwise, return null.
Tutorial: PHP exception
Get information about the previous exception:
<?php try { try { throw new Exception ( "An error occurred" , 1 ) ; } catch ( Exception $e1 ) { throw new Exception ( "Another error occurred" , 2 , $e1 ) ; } } catch ( Exception $e2 ) { $previous = $e2 -> getPrevious ( ) ; echo $previous -> getMessage ( ) ; } ?>
Try it yourself
$exception -> getPrevious ( )