-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathslack_error.rb
More file actions
35 lines (30 loc) · 854 Bytes
/
slack_error.rb
File metadata and controls
35 lines (30 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
module Slack
module Web
module Api
module Errors
class SlackError < ::Faraday::Error
attr_reader :response
def initialize(message, response = nil)
super message
@response = response
end
def error
response.body.error
end
def errors
response.body.errors
end
def response_metadata
response.body.response_metadata
end
def to_s
errors_message = ", errors=#{errors}" unless errors.nil?
response_metadata_message = ", response_metadata=#{response_metadata}" unless response_metadata.nil?
"#{error}#{errors_message || ''}#{response_metadata_message || ''}"
end
end
end
end
end
end