Sha256: ec0c74423e7483bf0b2aed1b21acfb9bead8812edb9333ab1d803a5bfe641448
Contents?: true
Size: 969 Bytes
Versions: 1
Compression:
Stored size: 969 Bytes
Contents
# frozen_string_literal: true module Slack module Web module Faraday module Response class RaiseError < ::Faraday::Response::Middleware def on_complete(env) raise Slack::Web::Api::Errors::TooManyRequestsError, env.response if env.status == 429 return unless env.success? body = env.body return unless body return if body['ok'] error_message = body['error'] || body['errors'].map { |message| message['error'] }.join(',') error_class = Slack::Web::Api::Errors::ERROR_CLASSES[error_message] error_class ||= Slack::Web::Api::Errors::SlackError raise error_class.new(error_message, env.response) end def call(env) super rescue ::Faraday::ParsingError raise Slack::Web::Api::Errors::ParsingError, env.response end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-ruby-client-1.0.0 | lib/slack/web/faraday/response/raise_error.rb |