Sha256: 35c4bbc313aeeb3ac2583ca4fe9372fba90dfaee8aca655dd8cff9789c6acc36

Contents?: true

Size: 717 Bytes

Versions: 6

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

module MyApiClient
  # The ancestor class for all API request error
  class Error < StandardError
    attr_reader :params

    delegate :metadata, to: :params
    alias to_bugsnag metadata

    # Initialize the error class
    #
    # @param params [MyApiClient::Params::Params]
    #   The request and response parameters
    # @param error_message [String]
    #   The error description
    def initialize(params, error_message = nil)
      @params = params
      super error_message
    end

    # Returns contents as string for to be readable for human
    #
    # @return [String] Contents as string
    def inspect
      { error: super, params: params }.inspect
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
my_api_client-0.22.0 lib/my_api_client/errors.rb
my_api_client-0.21.0 lib/my_api_client/errors.rb
my_api_client-0.20.0 lib/my_api_client/errors.rb
my_api_client-0.19.0 lib/my_api_client/errors.rb
my_api_client-0.18.0 lib/my_api_client/errors.rb
my_api_client-0.17.0 lib/my_api_client/errors.rb