Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
Created January 6, 2014 15:42
Show Gist options
  • Select an option

  • Save simonewebdesign/8284641 to your computer and use it in GitHub Desktop.

Select an option

Save simonewebdesign/8284641 to your computer and use it in GitHub Desktop.
Redefining Kernel module
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