How can I make a warning in the CATCH Template :: Toolkits block?

There is a bunch of blocks TRY/ CATCHin templates in the code I'm working in Template::Toolkit. They look like this:

[% TRY; x = OBJ.method(data); CATCH; "<!-- error: $error -->"; END %]

This is bad from two points of view. Firstly, the error is inserted into the HTML passed to the user, and secondly, the error is difficult to find for developers. In my opinion, all errors should be recorded in one error log. Now I am doing this through a function warn. I changed the code above to be

[% TRY %]
    [% x = OBJ.foo(data) %]
[% CATCH %]
    [% RAWPERL %]
        warn "error calling method foo on a bar object: " . $stash->get("error");
    [% END %]
[% END %]

but it is too verbose for what should be simple. Is there a better way I don't know to do this?

+5
source share
1 answer

! , .

! stderr STDERR:

[% FILTER stderr %]  
   Found a big problem
[% END %]

MVC, , .

- , - , :

[% logger.warn( " " )%]

, SMS- , .; -)

+8

All Articles