Skip to content

Instantly share code, notes, and snippets.

@jsanders
Created October 31, 2012 17:16
Show Gist options
  • Save jsanders/3988414 to your computer and use it in GitHub Desktop.
Save jsanders/3988414 to your computer and use it in GitHub Desktop.
Rescuable Exception
# Taken from a comment on http://www.mikeperham.com/2012/03/03/the-perils-of-rescue-exception/
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 SystemExit, SignalException
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