Class: BloodContracts::Instrumentation::FailedMatch

Inherits:
BC::ContractFailure
  • Object
show all
Defined in:
lib/blood_contracts/instrumentation/failed_match.rb

Overview

Wrapper for exception happend during the match instrumentation Should not be used in the app, to distinguish between expected and unexpected failures

Instance Method Summary collapse

Constructor Details

#initialize(exception, context: {}) ⇒ FailedMatch

Initialize failure type with exception

Parameters:

  • value (Exception)

    rescued exception from the type match

  • context (Hash) (defaults to: {})

    a customizable set of options

Options Hash (context:):

  • shared (Hash)

    context of matching pipeline



16
17
18
19
20
21
# File 'lib/blood_contracts/instrumentation/failed_match.rb', line 16

def initialize(exception, context: {})
  @errors = []
  @context = context
  @value = exception
  @context[:exception] = exception
end

Instance Method Details

#exceptionException

Reader for the exception caught

Returns:

  • (Exception)


36
37
38
# File 'lib/blood_contracts/instrumentation/failed_match.rb', line 36

def exception
  @context[:exception]
end

#valid?Boolean

Predicate, whether the data is valid or not (for the ExceptionCaught it is always False)

Returns:

  • (Boolean)


28
29
30
# File 'lib/blood_contracts/instrumentation/failed_match.rb', line 28

def valid?
  false
end