Skip to content

eventide-project/try

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published