class Sinatra::Base
def handle_exception!(boom)
def handle_exception!(boom) if error_params = @env['sinatra.error.params'] @params = @params.merge(error_params) end @env['sinatra.error'] = boom if boom.respond_to? :http_status and boom.http_status.between? 400, 599 status(boom.http_status) elsif settings.use_code? and boom.respond_to? :code and boom.code.between? 400, 599 status(boom.code) else status(500) end if server_error? dump_errors! boom if settings.dump_errors? raise boom if settings.show_exceptions? and settings.show_exceptions != :after_handler elsif not_found? headers['X-Cascade'] = 'pass' if settings.x_cascade? end if res = error_block!(boom.class, boom) || error_block!(status, boom) return res end if not_found? || bad_request? if boom.message && boom.message != boom.class.name body Rack::Utils.escape_html(boom.message) else content_type 'text/html' body '<h1>' + (not_found? ? 'Not Found' : 'Bad Request') + '</h1>' end end return unless server_error? raise boom if settings.raise_errors? or settings.show_exceptions? error_block! Exception, boom end