Rewrite Dancer2 Error objects #462

Open
veryrusty opened this Issue Sep 15, 2013 · 5 comments

4 participants

@veryrusty
PerlDancer member

From #209 (as its own issue, before it gets lost)

@xsawyerx : we should support send_error($hashref) at least.

@ambs
PerlDancer member

Thank you, @veryrusty.

@shumphrey

So, I think the way Dancer::Error does this is better than what we currently have in Dancer2::Core::Error.

I would like to backport something closer to the Dancer::Error/_render_serialized method.
This allows for send_error({ }) and send_error("").
Run time errors such as a die "oh no" and send_error(""), would result in a default hash something like:

{  error => "oh no" }

If show_error is 1 or

{ error => "Internal Server Error" }

if show_error is 0

The current code doesn't allow message hashrefs and forces the serialized error format to be of the form:

{
    message => $message,
    title => $title,
    status => $status,
    exception => $exception
}

I don't see a great way of being able to change the default runtime error format.

@xsawyerx
PerlDancer member

@mickeyn raised the idea of simply rewriting Dancer2::Core::Error. I'm very much in favor of it.

We could include the ability to do send_error($hashref) in its spec.

If others agree, should we open a new issue?

@shumphrey

I think a rewrite of Dancer2::Core::Error would be a good thing.

@xsawyerx xsawyerx changed the title from Add support for `send_error($hashref)` to Rewrite Dancer2 Error objects Sep 13, 2014
@xsawyerx
PerlDancer member

Small TODO reminder:

Core::Error should not be documented in the Cookbook or anywhere for the users to use. Users should only use send_error DSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment