Am Mittwoch, 23. März 2016 15:57:32 UTC+1 schrieb [email protected]:
>
>
> 1) In the Mojo callback function (/price route), invoking 
> Mojo::Exception->throw(message) triggers the rendering of the 
> exception.development.html.ep template from the __DATA__ section.  In the 
> template, the thrown message can be accessed as <%= $exception->message %>.
> 2) The rendered exception html (with the thrown message) is returned (with 
> a 500 response code) to the javascript / jquery script, caught by the.ajax. 
> fail handler, and accessable in the jqXHR object as jqXHR.responseText
>

Some more thoughts on this:
1) Remember that once you switch to production mode a different template 
("exception.production.html.ep") is used.
2) Also, if you modify the default exception template and an unexpected (by 
you) failure occurs during a regular request from a user, then the user 
will get to see a response based on the modified template.  Since you 
intended that to be consumed by your javascript code it won´t make much 
sense for the user.
3) I´d suggest having a look 
at 
http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Rendering-exception-and-not_found-pages.

Maybe explicitly selecting the appropriate template (and manually setting 
the response status code) is a more robust approach than relying on the 
standard exception templates.

- Heiko

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to