Sha256: f69510fdceff4d53709218073bd087aa0b4b34e6436c916bfc6b8785cd643820

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'domainic/attributer/errors/error'

module Domainic
  module Attributer
    # A specialized error class for coercion execution failures
    #
    # This error class is used when a coercion fails during attribute value
    # processing. It captures the failing coercer to provide context about which
    # step in the coercion chain caused the failure
    #
    # @author {https://aaronmallen.me Aaron Allen}
    # @since 0.2.0
    class CoercionExecutionError < Error
      # Get the coercer that failed
      #
      # @return [Proc, Symbol] the coercer that failed
      attr_reader :coercer #: Attribute::Coercer::handler

      # Initialize a new CoercionExecutionError instance
      #
      # @api private
      # @!visibility private
      #
      # @param message [String] the error message
      # @param coercer [Proc, Symbol] the coercer that failed
      #
      # @return [CoercionExecutionError] the new CoercionExecutionError instance
      # @rbs (String message, Attribute::Coercer::handler coercer) -> void
      def initialize(message, coercer)
        @coercer = coercer
        super(message)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
domainic-attributer-0.2.0 lib/domainic/attributer/errors/coercion_execution_error.rb