[Dancer-users] Masking warnings with eval/try in development mode?

Stéphane Wenric s.wenric at gmail.com
Mon Oct 15 09:04:46 CEST 2012


Hi,

I guess you could always disable warnings locally, before your function
call, and re-enable them after.
Something like

   eval {
      no warnings;
      do_something_that_might_fail();
      use warnings;
     $ok = 1;
   };

But then, yes, this means turning warnings off, but only for this specific
function.
Dunno if this helps

Steph

On Fri, Oct 12, 2012 at 10:51 PM, Assaf Gordon <gordon at cshl.edu> wrote:

> Hello,
>
> I'm working on a website, currently in 'development' mode.
> The config has "warnings: 1", meaning "treat warnings as critical errors",
> which is what I want 99% of the time.
>
> However,
> there's one place were I want to try something that might fail, and
> proceed without stopping the dancer application.
>
> Something like:
>
> ===
> get '/foobar' => sub
> {
>    my $ok;
>    eval {
>       do_something_that_might_fail();
>       $ok = 1;
>    };
>    template 'foobar', { ok => $ok } ;
> };
> ===
>
> However, in development mode with "warnings: 1", the "do_something" die()s
> and the dancer application stops with the standard HTTP 500 page with the
> stack trace.
>
> I don't want to turn "warnings" off, but I want to be able to mask this
> specific warning.
>
> Any ideas ?
>
> Thanks,
>  -gordon
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20121015/32793c1f/attachment.htm>


More information about the Dancer-users mailing list