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.13.0 lib/antbird/client/errors.rb
antbird-0.12.0 lib/antbird/client/errors.rb
antbird-0.11.0 lib/antbird/client/errors.rb
antbird-0.10.0 lib/antbird/client/errors.rb
antbird-0.9.0 lib/antbird/client/errors.rb
antbird-0.8.0 lib/antbird/client/errors.rb
antbird-0.7.0 lib/antbird/client/errors.rb
antbird-0.6.0 lib/antbird/client/errors.rb
antbird-0.5.3 lib/antbird/client/errors.rb
antbird-0.5.2 lib/antbird/client/errors.rb
antbird-0.5.1 lib/antbird/client/errors.rb
antbird-0.5.0 lib/antbird/client/errors.rb
antbird-0.4.0 lib/antbird/client/errors.rb
antbird-0.3.0 lib/antbird/client/errors.rb
antbird-0.2.2 lib/antbird/client/errors.rb
antbird-0.2.1 lib/antbird/client/errors.rb
antbird-0.2.0 lib/antbird/client/errors.rb
antbird-0.1.1 lib/antbird/client/errors.rb
antbird-0.1.0 lib/antbird/client/errors.rb
antbird-0.0.9 lib/antbird/client/errors.rb