As noted elsewhere, throwing an exception from the `finally` block will replace a previously thrown exception. But the original exception is magically available from the new exception's `getPrevious()`.
<?php
try {
try {
throw new RuntimeException('Exception A');
} finally {
throw new RuntimeException('Exception B');
}
}
catch (Throwable $exception) {
echo $exception->getMessage(), "\n";
// 'previous' is magically available!
echo $exception->getPrevious()->getMessage(), "\n";
}
?>
Will print:
Exception B
Exception A