Sha256: 634ae7323c7832918ce3254558df3a0eadae363ec3870385feb98ad9a702df74

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module LedgerSync
  class ResourceAttributeError < Error
    class TypeError < self
      attr_reader :attribute, :resource_class, :value

      def initialize(args = {})
        @attribute = args.fetch(:attribute)
        @resource_class = args.fetch(:resource_class)
        @value = args.fetch(:value)

        message = attribute.type.error_message(args)

        super(message: message)
      end
    end
  end

  class ResourceError < Error
    attr_reader :resource

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

    class ReferenceAssignmentError < self
      def initialize(attribute:, resource:, value:)
        resource_class = resource.class
        message = "Attribute #{attribute} value for #{resource_class.name} should be a #{asdf}.  Given: #{value.class}"

        super(message: message, resource: resource)
      end
    end

    class MissingResourceError < self
      attr_reader :resource_type, :resource_external_id

      def initialize(message:, resource_type:, resource_external_id:)
        @resource_type = resource_type
        @resource_external_id = resource_external_id
        super(message: message, resource: nil)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ledger_sync-1.3.5 lib/ledger_sync/error/resource_errors.rb