Exception: BrickFTP::HTTPClient::Error
- Inherits:
-
StandardError
- Object
- StandardError
- BrickFTP::HTTPClient::Error
- Defined in:
- lib/brick_ftp/http_client.rb
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/brick_ftp/http_client.rb', line 8 def initialize(response) begin error = JSON.parse(response.body) rescue error = { 'http-code' => response.code, 'error' => "#{response.message}, #{response.body}" } end case when !error.is_a?(Hash) super "#{response.code} #{response.message}" when error.key?('http-code') super "#{error['http-code']}: #{error['error']}" when error.key?('errors') super error['errors'].join('. ') else super 'unknown error.' end end |