As of PHP 8.0 you can use even cleaner way to catch your exceptions when you don't need to output the content of the error (from variable $e
). However you must replace default Exception
with Throwable
.
try {
/* something */
} catch (AError | BError) {
handler1()
} catch (Throwable) {
handler2()
}