Project

evt-try

0.0
No release in over 3 years
Low commit activity in last 3 years
Attempt an execution, and determine its success
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

try

Attempt an execution, and determine its success

Examples

Any Error

success = Try.() { }

puts success
# => true

success = Try.() { fail }

puts success
# => false

Specific Error

SomeError = Class.new(RuntimeError)

success = Try.(SomeError) { }

puts success
# => true

Try.(SomeError) { raise RuntimeError }
# => RuntimeError

success = Try.(SomeError) { raise SomeError }

puts success
# => false

List of Specific Errors

SomeError = Class.new(RuntimeError)
SomeOtherError = Class.new(RuntimeError)

success = Try.(SomeError, SomeOtherError) { }

puts success
# => true

Try.(SomeError, SomeOtherError) { raise RuntimeError }
# => RuntimeError

success = Try.(SomeError, SomeOtherError) { raise SomeOtherError }

puts success
# => false

License

The try library is released under the MIT License.