I'm just getting my feet wet with Mojolicious. One of the things I loved
immediately was Mojo::Template, so I've started using it also outside of
Mojolicious. I was very surprised to see error output on STDOUT without my
$SIG{__DIE__} kicking in.

So now I am curious as to why it returns Mojo::Exception objects on error
instead of die-ing them outright. This choice seems unusual to me, and I'd
like to understand why it is. The perldoc suggests:

my $mt = Mojo::Template->new;
say $mt->render(<<'EOF');
....
EOF

But really one cannot do that. One really needs to:

my $mt = Mojo::Template->new;
my $output = $mt->render(<<'EOF');
....
EOF
die $output if ref $output
say $output;

"die $$output if ref $$output;" is found in
Mojolicious/Plugin/EPLRenderer.pm and "return ref $output ? die $output :
$output;" is found in Mojolicious/Plugin/JSONConfig.pm, so I guess
Mojolicious itself also needs to do that.

The perldoc does say that ".... Mojo::Template will return Mojo::Exception
objects that stringify to error messages with context." but doesn't show
any such "die if exception" code in the actual examples.

Is there a good reason for this somewhat non-standard exception behavior?

Sincerely,

Peter

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to