Best point to catch 404/500 errors

43 views
Skip to first unread message

Brian Fox

unread,
May 6, 2013, 6:56:17 PM5/6/13
to google-s...@googlegroups.com
Hi -

Is there a good spot to detect and handle unbound REST calls? 

I'm looking specifically at this code inside WidgetRoutingDispatcher.java.  The bind and fireEvent methods will eventually resolve to null for any problematic REST call.  I'd like to be able to intercept the error and handle it gracefully with a consistent 400 reply without changing sitebrick code.

private void bindAndReply(HttpServletRequest request, HttpServletResponse response,
                            PageBook.Page page, Object instance) throws IOException {
    // bind request (sets request params, etc).
    binder.bind(request, instance);

    // call the appropriate handler.
    headlessRenderer.render(response, fireEvent(request, page, instance));

}


Any suggestions?

Thanks much,
Brian

Dhanji R. Prasanna

unread,
May 7, 2013, 7:11:56 AM5/7/13
to google-s...@googlegroups.com
Generally the servlet container itself has a method to do this. You can specify a 404 handler in web.xml I think

If you don't like this option, then register a filter that comes before sitebricks and  displays the corrected page.



--
You received this message because you are subscribed to the Google Groups "Google Sitebricks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-sitebri...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages