Skip to content

Instantly share code, notes, and snippets.

@memememomo
Created April 11, 2014 15:56
Show Gist options
  • Select an option

  • Save memememomo/10479810 to your computer and use it in GitHub Desktop.

Select an option

Save memememomo/10479810 to your computer and use it in GitHub Desktop.
Mojoliciousアプリ全体のエラー処理をする ref: http://qiita.com/uchiko/items/350bfd4ac1ed38279415
sub _exception {
my ($next, $c) = @_;
local $SIG{__DIE__}
= sub { ref $_[0] ? CORE::die($_[0]) : Mojo::Exception->throw(@_) };
$c->render_exception($@) unless eval { $next->(); 1 };
}
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