Projects
Mega:23.09
rubygem-sinatra
_service:tar_scm:Internal-Sinatra-errors-now-ex...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:Internal-Sinatra-errors-now-extend-Sinatra-Error.patch of Package rubygem-sinatra
From 084cf2ade353d3bf5f1a76aade87efd2f887bdd5 Mon Sep 17 00:00:00 2001 From: Jordan Owens <jkowens@gmail.com> Date: Thu, 31 Jan 2019 22:32:45 -0500 Subject: [PATCH] Internal Sinatra errors now extend Sinatra::Error --- lib/sinatra/base.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index f5d7729..aebd025 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -233,11 +233,14 @@ module Sinatra end end - class BadRequest < TypeError #:nodoc: + class Error < StandardError #:nodoc: + end + + class BadRequest < Error #:nodoc: def http_status; 400 end end - class NotFound < NameError #:nodoc: + class NotFound < Error #:nodoc: def http_status; 404 end end @@ -1114,15 +1117,16 @@ module Sinatra end @env['sinatra.error'] = boom - if boom.respond_to? :http_status - 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) + http_status = if boom.kind_of? Sinatra::Error + if boom.respond_to? :http_status + boom.http_status + elsif settings.use_code? && boom.respond_to?(:code) + boom.code + end end - status(500) unless status.between? 400, 599 + http_status = 500 unless http_status && http_status.between?(400, 599) + status(http_status) boom_message = boom.message if boom.message && boom.message != boom.class.name if server_error? -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2