Sha256: 579375a3be3137ad9e4dfb07192e24c647726af97a32acd9dbf824ddf5ecaff1
Contents?: true
Size: 887 Bytes
Versions: 10
Compression:
Stored size: 887 Bytes
Contents
# frozen_string_literal: true module Notion module Faraday module Response class RaiseError < ::Faraday::Response::Middleware 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'] error_message = 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_message, error_details, env.response) end def call(env) super rescue ::Faraday::ParsingError raise Notion::Api::Errors::ParsingError.new('parsing_error', env.response) end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems