Skip to content

Commit c8605d7

Browse files
committed
refactor(watson api exception): Adjust api exception class for better handling of exceptions
1 parent 3c1b864 commit c8605d7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/ibm_watson/watson_api_exception.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ def initialize(code: nil, error: nil, info: nil, transaction_id: nil, global_tra
1111
@error = response.reason
1212
unless response.body.empty?
1313
body_hash = JSON.parse(response.body.to_s)
14-
@code = body_hash["code"] || body_hash["error_code"]
15-
@error = body_hash["error"] || body_hash["error_message"]
16-
%w[code error_code error error_message].each { |k| body_hash.delete(k) }
14+
@code = body_hash["code"] || body_hash["error_code"] || body_hash["status"]
15+
@error = body_hash["error"] || body_hash["error_message"] || body_hash["statusInfo"] || body_hash["description"]
16+
%w[code error_code status error error_message statusInfo description].each { |k| body_hash.delete(k) }
1717
@info = body_hash
1818
end
1919
@transaction_id = transaction_id

0 commit comments

Comments
 (0)