-
-
Save patricknelson/94fd0c85b675177563d5 to your computer and use it in GitHub Desktop.
Hack to handle multiple Exception types with a single block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo extends Exception {} | |
class Bar extends Foo {} // Bar is a technically different but Foo-like exception. | |
class Baz extends Exception {} | |
try { | |
throw new Foo(); | |
} catch (Foo $e) { | |
echo 'Case 1'; | |
} catch (Baz $e) { | |
echo 'Case 2'; | |
} catch (Exception $e) { | |
// Apparently do nothing :) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment