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