Dancer2 icon indicating copy to clipboard operation
Dancer2 copied to clipboard

Allow send_error to send different content types

Open colinnewell opened this issue 7 years ago • 2 comments

In applications where there are routes outputting json and html functions like send_as make that work without too much of a problem. send_error appears to have all the logic to deal with a serializer, but it could do with a way of asking for a different one so that errors come out in a consistent format with the rest of the request rather than what the global application is configured for.

It looks relatively simple to implement assuming a reasonable syntax can be agreed upon for the helper. I'd be willing to create a pull request but I figured it was best to check it wasn't going to get shot down before doing so.

colinnewell avatar Apr 26 '17 13:04 colinnewell

This looks potentially useful, say with a send_error_as keyword.

Note that send_as started out as a plugin; which helped us iron out the syntax. You may want to consider the same approach for this.

veryrusty avatar Apr 27 '17 01:04 veryrusty

You would need to refactor the logic in send_as so it isn't repeated.

xsawyerx avatar May 02 '17 17:05 xsawyerx