Last active
November 8, 2015 06:23
-
-
Save dskecse/d0d230dd35c07a4d07a9 to your computer and use it in GitHub Desktop.
Disallowing double-raise
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
require 'English' | |
module NoDoubleRaisable | |
def error_handled! | |
$ERROR_INFO = nil | |
end | |
def raise(*args) | |
if $ERROR_INFO && args.first != $ERROR_INFO | |
warn "Double raise at #{caller.first}, aborting." | |
exit! false | |
else | |
super | |
end | |
end | |
end | |
class Object | |
include NoDoubleRaisable | |
end | |
if $0 == __FILE__ | |
begin | |
raise 'Initial failure' | |
rescue | |
# error_handled! | |
raise 'Secondary failure' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment