<%init> eval { #code that can throw errors }; if ($debug and ( UNIVERSAL::isa( $@,'HTML::Mason::Exception' )) { # let all Mason errors pass like usual if in debug mode $@->rethrow; } elsif ($@) { # catch all errors #stringify the error and call an error component $m->comp('error.mhtml', 'text' => "$@"); } #HTML code