Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 0.11.1 (Next)

* [#187](https://github.com/slack-ruby/slack-ruby-client/pull/187): Concatenate error message when multiple errors present - [@chrislopresto](https://github.com/chrislopresto).
* [#188](https://github.com/slack-ruby/slack-ruby-client/pull/188): Fixed `NoMethodError` when Slack is unavailable - [@sonicdoe](https://github.com/sonicdoe).
* Your contribution here.

### 0.11.0 (11/25/2017)
Expand Down
4 changes: 1 addition & 3 deletions lib/slack/web/faraday/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ class RaiseError < ::Faraday::Response::Middleware
def on_complete(env)
if env.status == 429
raise Slack::Web::Api::Errors::TooManyRequestsError, env.response
elsif (body = env.body) && body['ok']
nil
else
elsif (body = env.body) && !body['ok']
error_message = body['error'] || body['errors'].map { |message| message['error'] }.join(',')
raise Slack::Web::Api::Errors::SlackError.new(error_message, env.response)
end
Expand Down
14 changes: 14 additions & 0 deletions spec/fixtures/slack/web/503_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
http_interactions:
- request:
method: post
uri: https://slack.com/api/auth.test
response:
status:
code: 503
message: Service Unavailable
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Thu, 30 Nov 2017 14:36:26 GMT
14 changes: 14 additions & 0 deletions spec/slack/web/api/errors/service_unavailable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'spec_helper'

RSpec.describe Slack::Web::Client do
let(:client) { Slack::Web::Client.new }
it 'raises a Faraday::ClientError when Slack is unavailable', vcr: { cassette_name: 'web/503_error' } do
begin
client.auth_test
raise 'Expected to receive Faraday::ClientError.'
rescue Faraday::ClientError => e
expect(e.response).to_not be_nil
expect(e.response[:status]).to eq 503
end
end
end