Created
January 15, 2015 13:58
-
-
Save wouterj/74f762b27e08ea4e6b34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| $response = new \Response(); | |
| try { | |
| $client->buy('sofa'); | |
| } catch (\Exception $e) { | |
| foreach ($this->exceptionHandlers as $handler) { | |
| if ($handler->accepts($e)) { | |
| $response = $handler->handle($e, $response); | |
| } | |
| } | |
| } | |
| return $response; |
This file contains hidden or 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 NoProductsLeftHandler implements ExceptionHandler | |
| { | |
| public function accepts(\Exception $e) | |
| { | |
| return $e instanceof NoProductsLeft; | |
| } | |
| public function handle(\Exception $e, Response $response) | |
| { | |
| return new RedirectResponse('back'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment