Created
January 6, 2014 15:42
-
-
Save simonewebdesign/8284641 to your computer and use it in GitHub Desktop.
Redefining Kernel module
This file contains 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
class MyError < StandardError | |
end | |
module Kernel | |
def raise(*args) | |
# debugging... | |
puts "RAISE REDEFINED, and these are the *args:" | |
puts *args.inspect | |
if args[0] == MyError | |
puts "A MyError was raised. Nothing else must happen." | |
return | |
else | |
# fallback to default behaviour | |
Kernel.raise(*args) | |
end | |
end | |
end | |
# raise Exception, "A message." # normal behaviour | |
raise MyError, "This is my error." # doesn't actually raise an exception :) | |
puts "You should be able to read this because the exception wasn't raised!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment