Sha256: 6a9aef179bc2c6c8b5b725fd501b247294bd1641e1a4f75688c8bb86bd3bbcfd

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module LedgerSync
  class Error
    class AdaptorError < Error
      attr_reader :adaptor

      def initialize(adaptor:, message:)
        @adaptor = adaptor
        super(message: message)
      end

      class MissingAdaptorError < self
        def initialize(message:)
          super(message: message, adaptor: nil)
        end
      end

      class AdaptorValidationError < self
        attr_reader :attribute, :validation

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

      class ThrottleError < self
        attr_reader :rate_limiting_wait_in_seconds

        def initialize(adaptor:, message: nil)
          message ||= 'Your request has been throttled.'
          @rate_limiting_wait_in_seconds = LedgerSync.adaptors.config_from_klass(
            klass: adaptor.class
          ).rate_limiting_wait_in_seconds

          super(adaptor: adaptor, message: message)
        end
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ledger_sync-1.1.1 lib/ledger_sync/error/adaptor_errors.rb
ledger_sync-1.0.10 lib/ledger_sync/error/adaptor_errors.rb
ledger_sync-1.0.9 lib/ledger_sync/error/adaptor_errors.rb
ledger_sync-1.0.3 lib/ledger_sync/error/adaptor_errors.rb
ledger_sync-1.0.2 lib/ledger_sync/error/adaptor_errors.rb
ledger_sync-1.0.0 lib/ledger_sync/error/adaptor_errors.rb