Skip to content

Instantly share code, notes, and snippets.

@brianmed
Last active August 4, 2023 08:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmed/5795931 to your computer and use it in GitHub Desktop.
Save brianmed/5795931 to your computer and use it in GitHub Desktop.
#!/opt/perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
die("Here") if $self->param("exception");
$self->render("slash");
};
hook around_action => sub {
my ($next, $c, $action) = @_;
eval {
$c->$action();
};
if ($@) {
$c->render("exception", msg => $@);
}
};
app->start;
__DATA__
@@ slash.html.ep
Hello world.
@@ exception.html.ep
It exploded.
[% msg | html %]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment