Default Error Handler

18 views
Skip to first unread message

je...@jr4consulting.com

unread,
Nov 3, 2014, 1:26:33 PM11/3/14
to redsto...@googlegroups.com
Hi,

Newbie to Redstone (and Dart).

Looking at the docs, it appears that the @ErrorHandler annotation requires a particular status code.  Is there a way to define a default ('catch-all') error handler?  

In my particular scenario, I am trying to use Redstone to build a JSON-based API and do not want to ever return the HTML error page that seems to be returned in the event that the system raises a status code for which I have no explicit handler.

Thanks,
 Jesse

Luiz Mineo

unread,
Nov 4, 2014, 8:01:47 AM11/4/14
to redsto...@googlegroups.com
Hi Jesse!

Currently, there is no way to define an error handler to more than one http status code, but we can improve this in future releases.

Although, it's possible to implement this behavior with an interceptor. Example:

     @app.Interceptor("/.*", chainIdx: 0)
     errorHandler() {
        app.chain.next(() {
           if (app.response.statusCode != 200) {
             //handle error here
           }
        });
     }

Let me know if that helps.

Best regards,
Luiz.

je...@jr4consulting.com

unread,
Nov 4, 2014, 4:46:38 PM11/4/14
to redsto...@googlegroups.com
It definitely does.  Thanks!
Reply all
Reply to author
Forward
0 new messages