Sha256: 29a42b3db6ae991df2c2c4aff69b65357c27f3ccefcda038b314a83292cb3b72

Contents?: true

Size: 639 Bytes

Versions: 3

Compression:

Stored size: 639 Bytes

Contents

module Plaza
  class Error < ::StandardError
    attr_reader :response

    def initialize(response, message = nil)
      @response = response
      @message  = message || "Failed."
      @message << "  Response code = #{status}." if status
    end

    def status
      response.respond_to?(:status) ? response.status : nil
    end

    def to_s
      @message
    end
    alias :to_str :to_s
  end


  class ConnectionError < Error; end

  #422
  class ResourceInvalid < Error
    attr_reader :errors
    def initialize(response, message = nil, error_hash={})
      super(response, message)
      @errors = error_hash
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plaza-0.1.1 lib/plaza/models/error.rb
plaza-0.1.0 lib/plaza/models/error.rb
plaza-0.0.4 lib/plaza/models/error.rb