Last active
August 29, 2015 14:22
-
-
Save dhrrgn/d8f74e1cbbe3cd6ba63b 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 | |
| namespace Core\Middleware; | |
| use Slim\Middleware; | |
| /** | |
| * A Middleware implemenation which will send any exceptions to the Slim | |
| * error handler. | |
| * @package Core\Middleware | |
| */ | |
| abstract class AbstractMiddleware extends Middleware | |
| { | |
| /** | |
| * Do the Middleware processing. | |
| */ | |
| abstract protected function process(); | |
| /** | |
| * Wraps the middleware call in a try/catch and sends any errors | |
| * to the Slim error handler. | |
| */ | |
| public function call() | |
| { | |
| try { | |
| $this->process(); | |
| } catch (\Exception $e) { | |
| try { | |
| $this->app->error($e); | |
| } catch (\Slim\Exception\Stop $e) { | |
| // Do nothing | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment