[dancer-users] Automatic JSON serializer breaks error page

David Precious davidp at preshweb.co.uk
Fri Mar 14 10:20:43 GMT 2014


On Thu, 13 Mar 2014 18:57:04 -0600
Warren Young <warren at etr-usa.com> wrote:

> Apparently you cannot have both
> 
>     serializer: "JSON"
>     show_errors: 1
> 
> in your config.yml.  Enabling the automatic JSON serializer defeats
> the error screen, returning the exception error object as JSON to the
> client:
<snip>

You could argue that's correct and desired behaviour - if you have set
serialiser: "JSON", you are, presumably, writing an API, which will be
used by API consumers expecting JSON.  Suddenly dumping a HTML error
page at them instead of the JSON they were expecting would be silly and
wrong - returning JSON describing the error seems much more sane.

So, I wouldn't say it breaks the error page, I'd say it's logical
behaviour.

If you don't want it, though, you could probably get round it with
Yanick's suggestion of using before_serializer.


-- 
David Precious ("bigpresh") <davidp at preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github




More information about the dancer-users mailing list