Created
January 18, 2013 19:33
-
-
Save tysonmote/4567655 to your computer and use it in GitHub Desktop.
How to suppress all exceptions without a `rescue` clause.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bad | |
| raise 'oops' | |
| end | |
| def try | |
| result = yield | |
| ensure | |
| return result | |
| end | |
| try { bad } | |
| # nil | |
| ### | |
| def bad | |
| raise 'oops' | |
| end | |
| def try | |
| result = yield | |
| ensure | |
| result | |
| end | |
| try { bad } | |
| # 'oops' exception raised |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment