Exception: CartoDB::Client::Error
- Defined in:
- lib/cartodb-rb-client/cartodb/client/error.rb
Constant Summary collapse
- HTTP_MESSAGES =
{ 401 => 'Unauthorized request', 404 => 'Not found', 500 => 'Server error' }
Instance Attribute Summary collapse
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
- #custom_error(http_response) ⇒ Object
-
#initialize(uri = nil, method = nil, http_response = nil, error_message = nil) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(uri = nil, method = nil, http_response = nil, error_message = nil) ⇒ Error
Returns a new instance of Error.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cartodb-rb-client/cartodb/client/error.rb', line 12 def initialize(uri = nil, method = nil, http_response = nil, = nil) @uri = uri @method = method @error_messages = ['undefined CartoDB error'] @status_code = 400 @error_messages = [uri] if method == nil && http_response == nil && == nil @error_messages = [] if if http_response @status_code = http_response.code @error_messages = custom_error(http_response) || standard_error @body = http_response.body end end |
Instance Attribute Details
#status_code ⇒ Object
Returns the value of attribute status_code.
4 5 6 |
# File 'lib/cartodb-rb-client/cartodb/client/error.rb', line 4 def status_code @status_code end |
Instance Method Details
#custom_error(http_response) ⇒ Object
44 45 46 47 |
# File 'lib/cartodb-rb-client/cartodb/client/error.rb', line 44 def custom_error(http_response) json = Utils.parse_json(http_response) json[:error] if json end |
#to_s ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/cartodb-rb-client/cartodb/client/error.rb', line 28 def to_s = <<-EOF #{} #{} #{@body} EOF .strip end |