Sha256: e93cf817a3ed6385173549df8b06ff1de4e126d2ef14fca65734722cb32e568a

Contents?: true

Size: 1.71 KB

Versions: 11

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

module LedgerSync
  class Error
    class LedgerError < Error
      attr_reader :client, :response

      def initialize(client:, message:, response: nil)
        @client = client
        @response = response
        super(message: message)
      end

      class AuthenticationError < self; end
      class AuthorizationError < self; end
      class ConfigurationError < self; end

      class MissingLedgerError < self
        def initialize(message:)
          super(
            message: message,
            client: nil,
          )
        end
      end

      class LedgerValidationError < self
        attr_reader :attribute, :validation

        def initialize(message:, client:, attribute:, validation:)
          @attribute = attribute
          @validation = validation
          super(
            message: message,
            client: client,
          )
        end
      end

      class ThrottleError < self
        attr_reader :rate_limiting_wait_in_seconds

        def initialize(client:, message: nil, response: nil)
          message ||= 'Your request has been throttled.'
          @rate_limiting_wait_in_seconds = LedgerSync.ledgers.config_from_class(
            client_class: client.class
          ).rate_limiting_wait_in_seconds

          super(
            client: client,
            message: message,
            response: response
          )
        end
      end

      class UnknownURLFormat < self
        attr_reader :resource

        def initialize(*args, resource:, **keywords)
          super(
            *args,
            {
              message: "Unknown URL format for #{resource.class}"
            }.merge(keywords)
          )
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ledger_sync-2.0.2 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-2.0.1 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-2.0.0 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-2.0.0.pre.1 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-1.8.1 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-1.8.0 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-1.7.0 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-1.6.0 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-1.5.2 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-1.5.1 lib/ledger_sync/error/ledger_errors.rb
ledger_sync-1.5.0 lib/ledger_sync/error/ledger_errors.rb