Sha256: a84b98dc444a4033c65b04c9476e6b22164747878cc1d5db05d5df0f95dc766b

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module LedgerSync
  class Error
    class OperationError < Error
      attr_reader :operation, :response

      def initialize(message: nil, operation:, response: nil)
        message ||= 'Operation failed.'
        @operation = operation
        @response = response
        super(message: message)
      end

      class DuplicateLedgerResourceError < self; end
      class NotFoundError < self; end
      class LedgerValidationError < self; end
      class LedgerIDRequired < self
        def initialize(**keywords)
          super(
            {
              message: 'Resource ledger_id is required.'
            }.merge(keywords)
          )
        end
      end

      class PerformedOperationError < self
        def initialize(message: nil, operation:, response: nil)
          message ||= 'Operation has already been performed. Please check the result.'

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

      class ValidationError < self
        attr_reader :attribute,
                    :validation

        def initialize(message:, attribute:, operation:, validation:, response:nil)
          @attribute = attribute
          @validation = validation

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ledger_sync-1.3.3 lib/ledger_sync/error/operation_errors.rb
ledger_sync-1.3.2 lib/ledger_sync/error/operation_errors.rb
ledger_sync-1.3.1 lib/ledger_sync/error/operation_errors.rb