Sha256: e957aeb71eb0e111780bb9b47ad692096ca05370afd32f9c2eb94cec714f55c2

Contents?: true

Size: 675 Bytes

Versions: 2

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

module Cryptomus
  module Errors
    class Error < StandardError
    end

    class ApiError < Error
      # @!method response [Faraday::Response,nil]
      # @!method status [Integer,nil]
      # @!method response_body [Hash,nil]
      attr_reader :response, :status, :response_body

      # @param response [Faraday::Response,nil]
      # @param msg [String,nil]
      def initialize(response, msg = nil)
        @response = response
        @status = response&.status
        @response_body = response&.body
        msg ||= "Response #{status}, #{response_body}" if response
        super(msg || self.class.name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cryptomus-0.2.0 lib/cryptomus/errors.rb
cryptomus-0.1.1 lib/cryptomus/errors.rb