Sha256: ca11d845ca072d025bad23b0c0d66822d7b5ae14919e44553432885ce0b8fc10
Contents?: true
Size: 930 Bytes
Versions: 5
Compression:
Stored size: 930 Bytes
Contents
module BloodContracts::Core # Concern to wrap matching process with exception handling # # @example Defines a type with automatic exception handling in form of types # class JsonType < ::BC::Refined # prepend ExceptionHandling # # def match # @context[:parsed_json] = JSON.parse(value) # self # end # end # module ExceptionHandling # Runs the matching process and returns an ExceptionCaught if # StandardError happened inside match call # # @return [Refined] # def match super rescue StandardError => ex exception(ex) end # Wraps the exception in refinement type # # @param exc [Exception] raised exception # @option context [Hash] shared context of matching pipeline # @return [ExceptionCaught] # def exception(exc, context: @context) ExceptionCaught.new(exc, context: context) end end end
Version data entries
5 entries across 5 versions & 1 rubygems