Commit b7a0bee7 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Log Puma timeouts for API calls

This handles a specific exception raised
by `rack-timeout` Gem when Puma requests
surpass the configured timeout.

This exception wasn't being handled properly
(and logged), given it inherits from `Exception`,
which is not handled by Grape `rescue_from :all`.
parent 87c31380
......@@ -97,6 +97,15 @@ module API
handle_api_exception(exception)
end
# This is a specific exception raised by `rack-timeout` gem when Puma
# requests surpass its timeout. Given it inherits from Exception, we
# should rescue it separately. For more info, see:
# - https://github.com/sharpstone/rack-timeout/blob/master/doc/exceptions.md
# - https://github.com/ruby-grape/grape#exception-handling
rescue_from Rack::Timeout::RequestTimeoutException do |exception|
handle_api_exception(exception)
end
format :json
content_type :txt, "text/plain"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment