module Atacama
Constants
- OptionTypeMismatchError
- ResultTypeMismatchError
- ReturnTypeMismatchError
- VERSION
Public Class Methods
check(type, value) { |exception| ... }
click to toggle source
Execute a type check, catch and yield if theres an error.
@yields [Exception] the caught type error
@param type [Dry::Types?] type to check @param value [Object] object to execute with
# File lib/atacama.rb, line 20 def self.check(type, value) type && type[value] nil rescue Dry::Types::ConstraintError => exception yield exception end
format_exception(klass, exception, description)
click to toggle source
Generate more human readable error messages for type errors.
@param klass [Class] the class dispatching the exception @param exception [Dry::Types::]
# File lib/atacama.rb, line 31 def self.format_exception(klass, exception, description) [ '', '', 'Source:', " #{klass}", '', 'Description:', " #{description}", '', 'Error:', " The value #{exception.input.inspect} failed the following test: #{exception.result}", '' ].join("\n") end