Sha256: 484830b0d9cf4b6a0421501b7af9f355bf42c8211fe227f170d5703da7a6734d

Contents?: true

Size: 775 Bytes

Versions: 8

Compression:

Stored size: 775 Bytes

Contents

module Finix

  class ResourceErrors < ::StandardError
    attr_reader :response
    attr_reader :errors

    def initialize(response=nil)
      @response = response
      @errors = []
      @response[:body]['_embedded']['errors'].each { |error| @errors.push Finix::ResourceError.new error}
    end

    def to_s
      "#{@errors}"
    end
  end

  class ResourceError
    attr_reader :attributes

    def initialize(error = {})
      @attributes = {}
      @attributes = @attributes.merge error
    end
  end

  class BadRequest < ResourceErrors; end
  class Unauthorized < ResourceErrors; end
  class Forbidden < ResourceErrors; end
  class NotFound < ResourceErrors; end
  class MethodNotAllowed < ResourceErrors; end
  class UnprocessableEntity < ResourceErrors; end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
finix-0.9 lib/finix/error.rb
finix-0.8 lib/finix/error.rb
finix-0.7 lib/finix/error.rb
finix-0.6 lib/finix/error.rb
finix-0.5 lib/finix/error.rb
finix-0.4 lib/finix/error.rb
finix-0.3 lib/finix/error.rb
finix-0.2 lib/finix/error.rb