Skip to content

Commit

Permalink
fix(ruby-grape#1922): Send endpoint parameter as the last param of th…
Browse files Browse the repository at this point in the history
…e run_rescue_handler method
  • Loading branch information
jcagarcia committed Nov 23, 2023
1 parent cef14da commit 229875e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/grape/middleware/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def call!(env)
rescue_handler_for_any_class(e.class) ||
raise

run_rescue_handler(@env[Grape::Env::API_ENDPOINT], handler, e)
run_rescue_handler(handler, e, @env[Grape::Env::API_ENDPOINT])
end
end

Expand Down Expand Up @@ -119,7 +119,7 @@ def rescue_handler_for_any_class(klass)
options[:all_rescue_handler] || :default_rescue_handler
end

def run_rescue_handler(endpoint, handler, error)
def run_rescue_handler(handler, error, endpoint)
if handler.instance_of?(Symbol)
raise NoMethodError, "undefined method '#{handler}'" unless respond_to?(handler)

Expand All @@ -135,7 +135,7 @@ def run_rescue_handler(endpoint, handler, error)
if response.is_a?(Rack::Response)
response
else
run_rescue_handler(endpoint, :default_rescue_handler, Grape::Exceptions::InvalidResponse.new)
run_rescue_handler(:default_rescue_handler, Grape::Exceptions::InvalidResponse.new, endpoint)
end
end

Expand Down

0 comments on commit 229875e

Please sign in to comment.