seancribbs/webmachine-ruby — Issue #11: Generic error handling
Author: seancribbs
Created: 2011-10-10 23:29:52+00:00
State: open

I'm trying to find the appropriate place to hook into to capture errors in a generic fashion, so as to render a custom 500 response body. I see that the Webmachine#render_error does take options, but that those options only apply to values that are added to the standard body response.

Perhaps webmachine could provide a callback that takes the error with the default implementation to simply raise it again (and then rescuing to the current workflow)?

# callbacks.rb
def handle_error(e, state)
raise e
end

# fsm.rb
rescue => e # Handle all exceptions without crashing the server
resource.handle_error(e, state) rescue error_response(e, state)
end