Sha256: f354ec0f5b46e88f2fdb0fabda42f85cb0c50d71d92b4db7a5a8d5d6a8a1d9dc

Contents?: true

Size: 498 Bytes

Versions: 27

Compression:

Stored size: 498 Bytes

Contents

module Antbird
  class Client
    class Error < StandardError; end

    class ApiError < Error
      def initialize(response)
        @response = response
        @status   = response.status

        body = response.body
        @error = body["error"] if body.is_a?(Hash) && body.key?("error")

        message = @error || body.to_s
        super message
      end
      attr_reader :response, :status
    end

    class ServerError < ApiError; end
    class RequestError < ApiError; end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
antbird-0.0.8 lib/antbird/client/errors.rb
antbird-0.0.7 lib/antbird/client/errors.rb
antbird-0.0.6 lib/antbird/client/errors.rb
antbird-0.0.5 lib/antbird/client/errors.rb
antbird-0.0.4 lib/antbird/client/errors.rb
antbird-0.0.3 lib/antbird/client/errors.rb
antbird-0.0.2 lib/antbird/client/errors.rb