Exception: ChatWork::ChatWorkError
- Inherits:
-
StandardError
- Object
- StandardError
- ChatWork::ChatWorkError
- Defined in:
- lib/chatwork/chatwork_error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error_response ⇒ Object
readonly
Returns the value of attribute error_response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, status = nil, error_response = nil) ⇒ ChatWorkError
constructor
A new instance of ChatWorkError.
Constructor Details
#initialize(message, status = nil, error_response = nil) ⇒ ChatWorkError
Returns a new instance of ChatWorkError.
26 27 28 29 30 |
# File 'lib/chatwork/chatwork_error.rb', line 26 def initialize(, status = nil, error_response = nil) @status = status @error_response = error_response super() end |
Instance Attribute Details
#error_response ⇒ Object (readonly)
Returns the value of attribute error_response.
24 25 26 |
# File 'lib/chatwork/chatwork_error.rb', line 24 def error_response @error_response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
24 25 26 |
# File 'lib/chatwork/chatwork_error.rb', line 24 def status @status end |
Class Method Details
.from_response(status, body, headers) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/chatwork/chatwork_error.rb', line 3 def self.from_response(status, body, headers) body ||= {} if headers.has_key?("WWW-Authenticate") return AuthenticateError.from_www_authenticate( www_authenticate: headers["WWW-Authenticate"], status: status, error_response: body["errors"], ) end return APIError.new(status, body["errors"]) if body["errors"] if body["error"] = [body["error"], body["error_description"]].compact.join(" ") return AuthenticateError.new(, status, body, body["error"], body["error_description"]) end APIConnectionError.new("Invalid response #{body.to_hash} (status: #{status})") end |