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
"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