Sha256: 8a10fc6288805ac4a4cbdecb212158a202801c897d2a89267fa6f0f286a96073

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

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

  # Base exception class for errors thrown by the Parse
  # client library. AVError will be raised by any
  # network operation if AV.init() has not been called.
  class AVError < 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 AVProtocolError < AVError
    attr_accessor :code
    attr_accessor :error
    attr_accessor :response
    attr_accessor :http_status_code

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

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

    def to_s
      @message || super
    end

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

  class AVProtocolRetry < AVProtocolError
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
leancloud-ruby-client-0.1.1 lib/leancloud/error.rb
leancloud-ruby-client-0.1.0 lib/leancloud/error.rb