Class: Notion::Faraday::Response::RaiseError
- Inherits:
-
Faraday::Response::Json
- Object
- Faraday::Response::Json
- Notion::Faraday::Response::RaiseError
- Defined in:
- lib/notion/faraday/response/raise_error.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 |
# File 'lib/notion/faraday/response/raise_error.rb', line 23 def call(env) super rescue ::Faraday::ParsingError raise Notion::Api::Errors::ParsingError.new('parsing_error', env.response) end |
#on_complete(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/notion/faraday/response/raise_error.rb', line 6 def on_complete(env) raise Notion::Api::Errors::TooManyRequests, env.response if env.status == 429 return if env.success? body = env.body return unless body error_code = body['code'] = body['message'] error_details = body['details'] error_class = Notion::Api::Errors::ERROR_CLASSES[error_code] error_class ||= Notion::Api::Errors::NotionError raise error_class.new(, error_details, env.response) end |