module Dry::Monads::Try::Mixin::Constructors
@private
Public Instance Methods
Try(*exceptions, &f)
click to toggle source
A convenience wrapper for {Monads::Try.run}. If no exceptions are provided it falls back to StandardError. In general, relying on this behaviour is not recommended as it can lead to unnoticed bugs and it is always better to explicitly specify a list of exceptions if possible.
@param exceptions [Array<Exception>] @return [Try]
# File lib/dry/monads/try.rb, line 271 def Try(*exceptions, &f) catchable = exceptions.empty? ? DEFAULT_EXCEPTIONS : exceptions.flatten Try.run(catchable, f) end