Created
April 11, 2014 15:56
-
-
Save memememomo/10479810 to your computer and use it in GitHub Desktop.
Mojoliciousアプリ全体のエラー処理をする ref: http://qiita.com/uchiko/items/350bfd4ac1ed38279415
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
| sub _exception { | |
| my ($next, $c) = @_; | |
| local $SIG{__DIE__} | |
| = sub { ref $_[0] ? CORE::die($_[0]) : Mojo::Exception->throw(@_) }; | |
| $c->render_exception($@) unless eval { $next->(); 1 }; | |
| } |
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
| app->hook(around_dispatch => sub { | |
| my ($next, $c) = @_; | |
| eval { $next->(); 1; }; | |
| # アプリにエラーが起こった場合 | |
| if ($@) { | |
| $c->app->log->fatal('SYSTEM ERROR!!: '.$@); | |
| die $@; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment