Merge pull request #23 from mbethke/master
Fix error handling problem (closes #22)
This commit is contained in:
@@ -85,9 +85,7 @@ sub _render {
|
|||||||
# Error
|
# Error
|
||||||
unless ($ok) {
|
unless ($ok) {
|
||||||
|
|
||||||
my $e = Mojo::Exception->new(
|
my $e = Mojo::Exception->new($self->tt->error.'');
|
||||||
$self->tt->error.'',
|
|
||||||
$self->tt->service->process(defined $inline ? \$inline : $t));
|
|
||||||
$$output = '';
|
$$output = '';
|
||||||
$c->app->log->error(qq/Template error in "$t": $e/);
|
$c->app->log->error(qq/Template error in "$t": $e/);
|
||||||
$c->render_exception($e);
|
$c->render_exception($e);
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
foo
|
||||||
|
[% PROCESS doesnotexist.tt IF do_process %]
|
||||||
|
bar
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ BEGIN { $ENV{MOJO_TMPDIR} ||= File::Temp::tempdir }
|
|||||||
# Make sure sockets are working
|
# Make sure sockets are working
|
||||||
plan skip_all => 'working sockets required for this test!'
|
plan skip_all => 'working sockets required for this test!'
|
||||||
unless Mojo::IOLoop->new->generate_port;
|
unless Mojo::IOLoop->new->generate_port;
|
||||||
plan tests => 3;
|
plan tests => 6;
|
||||||
|
|
||||||
# Leela: OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can.
|
# Leela: OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can.
|
||||||
# Farnsworth: You're going to do his laundry?
|
# Farnsworth: You're going to do his laundry?
|
||||||
@@ -30,13 +30,18 @@ plugin 'tt_renderer';
|
|||||||
app->log->level('error');
|
app->log->level('error');
|
||||||
|
|
||||||
# GET /
|
# GET /
|
||||||
get '/' => 'index';
|
get '/' => 'index';
|
||||||
|
get '/blow' => sub {
|
||||||
|
shift->render(template => 'conditional-exception', do_process => 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
my $t = Test::Mojo->new;
|
my $t = Test::Mojo->new;
|
||||||
|
|
||||||
# Simple TT template
|
# Simple TT template
|
||||||
$t->get_ok('/')->status_is(200)
|
$t->get_ok('/')->status_is(200)
|
||||||
->content_like(qr/test123456/);
|
->content_like(qr/test123456/);
|
||||||
|
$t->get_ok('/blow')->status_is(500)->content_like(qr/file error - doesnotexist.tt: No such file or directory/);
|
||||||
|
|
||||||
eval "
|
eval "
|
||||||
use Devel::Cycle 'find_cycle';
|
use Devel::Cycle 'find_cycle';
|
||||||
|
|||||||
Reference in New Issue
Block a user