Sha256: cc0ef85c643ee358edd02e4db31b94a11e798405bc3e9648c91877c26769bce2

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module BloodContracts
  module Instrumentation
    # Wrapper for exception happend during the match instrumentation
    # Should not be used in the app, to distinguish between expected and
    # unexpected failures
    class FailedMatch < ::BC::ContractFailure
      # Initialize failure type with exception
      #
      # @param value [Exception] rescued exception from the type match
      # @option context [Hash] shared context of matching pipeline
      #
      # @return [FailedMatch]
      #
      def initialize(exception, context: {})
        @errors = []
        @context = context
        @value = exception
        @context[:exception] = exception
      end

      # Predicate, whether the data is valid or not
      # (for the ExceptionCaught it is always False)
      #
      # @return [Boolean]
      #
      def valid?
        false
      end

      # Reader for the exception caught
      #
      # @return [Exception]
      #
      def exception
        @context[:exception]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blood_contracts-instrumentation-0.1.1 lib/blood_contracts/instrumentation/failed_match.rb
blood_contracts-instrumentation-0.1.0 lib/blood_contracts/instrumentation/failed_match.rb