Text::...hErrors(3pm)
π Text::MicroMason::CatchErrors β no cap, bestie π
okay so this is the Perl manpage for Text::MicroMason::CatchErrors, living in the User Contributed Perl Documentation corner of the world. it adds exception catching for templates. that's the whole vibe. π«Ά
β¨ NAME β¨
Text::MicroMason::CatchErrors β adds exception catching for templates, periodt.
π SYNOPSIS π
okay first thing, do not use this class directly, bestie. it's a mixin. you pass its name in and let it do its thing:
use Text::MicroMason;
my $mason = Text::MicroMason->new( -CatchErrors );
then you use the standard compile and execute methods to parse and evaluate templates, like the icon that you are:
print scalar $mason->compile( text=>$template )->( @%args );
print scalar $mason->execute( text=>$template, @args );
and here's the slay part: the result is undef on exception, plus an error message if you're in list context:
($coderef, $error) = $mason->compile( text=>$template );
($result, $error) = $mason->execute( text=>$template, 'name'=>'Dave' );
it's giving "check a variable instead of wrapping everything in eval." iconic.
π DESCRIPTION π
so this package adds exception catching to MicroMason, which means you get to check an error variable instead of wrapping every single call in an eval. no more chaos. no more eval everywhere like it's 2003.
both compilation and run-time errors in your template are handled as fatal exceptions. and like, here's the thing β the base MicroMason class will croak() if you attempt to compile or execute a template that contains an incorrect fragment of Perl syntax. π and similarly, if the Perl code in your template causes die() or croak() to be called, that will interrupt your program unless it's caught by an eval block. that's just how it is, ngl.
this class provides that error catching behavior for the compile and execute methods. it's literally the whole job.
so in a scalar context they return the result of the call, orundefif it failed; in a list context they return the results of the call (undefif it failed) followed by the error message (undefif it succeeded). π
πΈ Public Methods πΈ
compile()β uses anevalblock to provide an exception catching wrapper for thecompilemethod. π¦
$code_ref = $mason->compile( text => $template, %options );
($coderef, $error) = $mason->compile( text=>$template, %options );
execute()β uses anevalblock to provide an exception catching wrapper for theexecutemethod. β¨
$result = $mason->execute( text => $template, @arguments );
($result, $error) = $mason->execute( text=>$template, 'name'=>'Dave' );
π SEE ALSO π
- for an overview of this templating framework, see
Text::MicroMason. π - this is a mixin class intended for use with
Text::MicroMason::Base. π§ - for distribution, installation, support, copyright and license information, see
Text::MicroMason::Docs::ReadMe. π
okay that's the whole page, bestie, you ate that. π
this was perl v5.36.0, dated 2023-08-10, and it's the Text::MicroMason::CatchErrors page from the User Contributed Perl Documentation. mwah π
π¦ where this page comes from
- debian trixie: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms