Class: Lockstep::Error
- Inherits:
-
Object
- Object
- Lockstep::Error
- Defined in:
- app/concepts/lockstep/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
ParseError actually represents both HTTP & parse.com error codes.
-
#error ⇒ Object
ParseError actually represents both HTTP & parse.com error codes.
-
#msg ⇒ Object
ParseError actually represents both HTTP & parse.com error codes.
Instance Method Summary collapse
-
#initialize(code, msg = "") ⇒ Error
constructor
A new instance of Error.
- #to_array ⇒ Object
Constructor Details
#initialize(code, msg = "") ⇒ Error
Returns a new instance of Error.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/concepts/lockstep/error.rb', line 10 def initialize(code, msg="") @msg = msg @code = code case code.to_s when "111" @error = "Invalid type." when "135" @error = "Unknown device type." when "202" @error = "Username already taken." when "203" @error = "Email already taken." when "400" @error = "Bad Request: The request cannot be fulfilled due to bad syntax." when "401" @error = "Unauthorized: Check your App ID & Master Key." when "403" @error = "Forbidden: You do not have permission to access or modify this." when "408" @error = "Request Timeout: The request was not completed within the time the server was prepared to wait." when "415" @error = "Unsupported Media Type" when "500" @error = "Internal Server Error" when "502" @error = "Bad Gateway" when "503" @error = "Service Unavailable" when "508" @error = "Loop Detected" else @error = "Unknown Error" raise "Parse error #{code}: #{@error} #{@msg}" end end |
Instance Attribute Details
#code ⇒ Object
ParseError actually represents both HTTP & parse.com error codes. If the HTTP response is 400, one can inspect the first element of the error converted to_array for the HTTP error code and the 2nd element for the parse error response.
6 7 8 |
# File 'app/concepts/lockstep/error.rb', line 6 def code @code end |
#error ⇒ Object
ParseError actually represents both HTTP & parse.com error codes. If the HTTP response is 400, one can inspect the first element of the error converted to_array for the HTTP error code and the 2nd element for the parse error response.
6 7 8 |
# File 'app/concepts/lockstep/error.rb', line 6 def error @error end |
#msg ⇒ Object
ParseError actually represents both HTTP & parse.com error codes. If the HTTP response is 400, one can inspect the first element of the error converted to_array for the HTTP error code and the 2nd element for the parse error response.
6 7 8 |
# File 'app/concepts/lockstep/error.rb', line 6 def msg @msg end |
Instance Method Details
#to_array ⇒ Object
46 47 48 |
# File 'app/concepts/lockstep/error.rb', line 46 def to_array [ @code, @msg ] end |