Am Mittwoch, 23. März 2016 15:57:32 UTC+1 schrieb [email protected]: > A more general question, is this a good way to handle exceptions caught in > mojo callback functions? An alternative would be to not throw an > exception and instead, render error data that gets returned to the .ajax > .done handler (200 response code). The .done handler is then responsible > to detect the error values and display an error message to the user. This > would not generate the 500 response code which could still be thrown by the > http server. >
Oh my, I´m always struggling with that question myself. :-] I honestly don´t know if there´s a "correct" answer to that question. There´s those - especially with a REST background - who say that you should use the HTTP status codes for signalling application state. And then there´s those who tell you that if your code handled the situation then you should go with a HTTP status code indicating success and put error codes in app specific data structures; leaving HTTP status codes and especially error codes for those situations where your server side code didn´t cope with the situation. Of course you could also use a HTTP error status _and_ return a data structure with additional information. The answer may even depend on wether you´re talking about an API or a user interface. Maybe it´s just again a case of "select one option and stick with it". Or maybe someone in this group with more experience can chime in and give some better advice... I would be interested in hearing it, too. - 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.
