Created
April 8, 2013 20:22
-
-
Save banister/5340133 to your computer and use it in GitHub Desktop.
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
# As a REPL, we often want to catch any unexpected exceptions that may have | |
# been raised; however we don't want to go overboard and prevent the user | |
# from exiting Pry when they want to. | |
module RescuableException | |
def self.===(exception) | |
case exception | |
# Catch when the user hits ^C (Interrupt < SignalException), and assume | |
# that they just wanted to stop the in-progress command (just like bash etc.) | |
when Interrupt | |
true | |
# Don't catch signals (particularly not SIGTERM) as these are unlikely to be | |
# intended for pry itself. We should also make sure that Kernel#exit works. | |
when *Pry.config.exception_whitelist | |
false | |
# All other exceptions will be caught. | |
else | |
true | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment