Exception: Parse::ParseProtocolError

Inherits:
ParseError
  • Object
show all
Defined in:
lib/parse/error.rb

Overview

An exception class raised when the REST API returns an error. The error code and message will be parsed out of the HTTP response, which is also included in the response attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ParseProtocolError

Returns a new instance of ParseProtocolError.



17
18
19
20
21
22
23
24
25
# File 'lib/parse/error.rb', line 17

def initialize(response)
  @response = response
  if response
    @code = response["code"]
    @error = response["error"]
  end

  super("#{@code}: #{@error}")
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



13
14
15
# File 'lib/parse/error.rb', line 13

def code
  @code
end

#errorObject

Returns the value of attribute error.



14
15
16
# File 'lib/parse/error.rb', line 14

def error
  @error
end

#responseObject

Returns the value of attribute response.



15
16
17
# File 'lib/parse/error.rb', line 15

def response
  @response
end

Instance Method Details

#message=(msg) ⇒ Object



31
32
33
# File 'lib/parse/error.rb', line 31

def message=(msg)
  @message = msg
end

#to_sObject



27
28
29
# File 'lib/parse/error.rb', line 27

def to_s
  @message || super
end