lib/webmachine/resource/callbacks.rb in webmachine-0.4.2 vs lib/webmachine/resource/callbacks.rb in webmachine-1.0.0

- old
+ new

@@ -358,9 +358,25 @@ # constructed and sent. The return value is ignored, so any effect # of this method must be by modifying the response. # @api callback def finish_request; end + # + # This method is called when an exception is raised within a subclass of + # {Webmachine::Resource}. + # + # @param [Exception] e + # The exception. + # + # @return [void] + # + # @api callback + # + def handle_exception(e) + response.error = [e.message, e.backtrace].flatten.join("\n ") + Webmachine.render_error(500, request, response) + end + # This method is called when verifying the Content-MD5 header # against the request body. To do your own validation, implement # it in this callback, returning true or false. To bypass header # validation, simply return true. Default is nil, which will # invoke Webmachine's default validation.