Skip to content

Instantly share code, notes, and snippets.

@jberger
Created December 27, 2016 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberger/f14196786af26aafa416b2fe3f27b95f to your computer and use it in GitHub Desktop.
Save jberger/f14196786af26aafa416b2fe3f27b95f to your computer and use it in GitHub Desktop.
use Mojolicious::Lite;
under sub {
my $c = shift;
$c->stash->{format} = $c->accepts('json', 'html');
};
get '/' => sub { die 'argh' };
app->start;
__DATA__
@@ exception.json.ep
%== Mojo::JSON::encode_json({error => $exception->message});
@@ exception.html.ep
<div class="error">
%= $exception->message
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment