Sha256: ba5d88fd6a8a310b717009783e6342073b42d033168bc02d50896299fa4df25b

Contents?: true

Size: 691 Bytes

Versions: 1

Compression:

Stored size: 691 Bytes

Contents

module Ki
  class ApiError < StandardError
    attr_reader :status

    def initialize body, status=400
      super body
      @status = status
    end

    def result
      { 'error' => to_s }
    end
  end

  class InvalidUrlError < ApiError; end
  class RequiredAttributeMissing < ApiError; end
  class AttributeNotUnique < ApiError; end
  class ForbiddenAction < ApiError
    def initialize s='forbidden', code=403
      super s, code
    end
  end
  class UnauthorizedError < ApiError
    def initialize s='unauthroized', code=401
      super s, code
    end
  end
  class PartialNotFoundError < ApiError
    def initialize s
      super "partial #{s} not found", 404
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ki-0.4.2 lib/ki/api_error.rb