class BloodContracts::Core::ExceptionCaught

Refinement type which holds exception as a value

Public Class Methods

new(value = nil, context: {}, **) click to toggle source

Constructs refinement type around exception

@param value [Exception] value which is wrapped inside the type @option context [Hash] shared context of types matching pipeline

# File lib/blood_contracts/core/exception_caught.rb, line 9
def initialize(value = nil, context: {}, **)
  @errors = []
  @context = context
  @value = value
  @context[:exception] = value
end

Public Instance Methods

exception() click to toggle source

Reader for the exception caught

@return [Exception]

# File lib/blood_contracts/core/exception_caught.rb, line 29
def exception
  @context[:exception]
end
valid?() click to toggle source

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

@return [Boolean]

# File lib/blood_contracts/core/exception_caught.rb, line 21
def valid?
  false
end