Sha256: 784c9006167ed8659514a27caa94618df031bb18aadb6f3bce39c40bb2283c85

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module LedgerSync
  class ResourceError < Error
    attr_reader :resource

    def initialize(message:, resource:)
      @resource = resource
      super(message: message)
    end
    class AttributeTypeError < self
      attr_reader :attribute, :resource, :value

      def initialize(attribute:, resource:, value:)
        @attribute = attribute
        @resource = resource
        @value = value

        resource_class = resource.class

        message = "Attribute #{attribute.name} for #{resource_class.name} should be a class supported by #{attribute.type.class.name}.  Given: #{value.class}"

        super(message: message, resource: nil)
      end
    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.1.1 lib/ledger_sync/error/resource_errors.rb