Sha256: 67a3a58134690a8ed37f7ef5ec1de6abe93b060c7ea8f05aacc294894cb7c1d4

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

# -*- encoding : utf-8 -*-
module Parse

  # Base exception class for errors thrown by the Parse
  # client library. ParseError will be raised by any
  # network operation if Parse.init() has not been called.
  class ParseError < StandardError #Exception ... why? A:http://www.skorks.com/2009/09/ruby-exceptions-and-exception-handling/
  end

  # 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.
  class ParseProtocolError < ParseError
    attr_accessor :code
    attr_accessor :error
    attr_accessor :response

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

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

    def to_s
      @message || super
    end

    def message=(msg)
      @message = msg
    end
  end

  class ParseProtocolRetry < ParseProtocolError
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parse-ruby-client-0.3.0 lib/parse/error.rb