[dancer-users] Using Dancer::Exception -- searching for best patterns

Hermann Calabria hermann at ivouch.com
Wed Jan 13 18:08:45 GMT 2016


I took a look at your module and really like your work, thank you.  You also 
inspired me to take a closer look at D2 and I now see there's little point 
in refactoring our entire D1 app to handle exceptions "properly", because 
the refactor would be just another kludge.  The better course of action 
appears to be to plan an eventual migration to D2, and use 
Dancer2::Plugin::LogReport.

-----Original Message----- 
From: Andrew Beverley
Sent: Wednesday, January 13, 2016 7:41 AM
To: Perl Dancer users mailing list
Subject: Re: [dancer-users] Using Dancer::Exception -- searching for best 
patterns

On Tue, 2016-01-12 at 16:32 -0800, Hermann Calabria wrote:
> Ideally I’d like to Raise Friendly => ‘Some Friendly Error Message’ to
> report user-friendly error messages without logging, and everything
> else (whether raised by Dancer, die(), or by something else such as a
> database error) should just report “Internal Server Error” and log it.
>
> Furthermore, I’d like to be able to use Raise Friendly => ‘Some
> Friendly Error Message’ anywhere within the route code or within any
> package used by the route (example below uses Some::Package).

I wrote (with a little help) Dancer2::Plugin::LogReport for a
comprehensive and easy way to do this and a bunch of other stuff, whilst
keeping code to a minimum. I'm just about to post an article to the
mailing list about it.

I realise you're using Dancer1, but you might like to look at the
techniques involved, or even consider porting it to Dancer1 if it would
be of benefit to you.

> 1. I don’t want to repeat the same catch {} section within every
> single route (following principles of D.R.Y.),

That's exactly the idea behind the module - I got very bored writing
code similar to that in your examples.

Andy


_______________________________________________
dancer-users mailing list
dancer-users at dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users 



More information about the dancer-users mailing list