Skip to content

Instantly share code, notes, and snippets.

@joshnesbitt
Created October 20, 2010 12:07
Show Gist options
  • Select an option

  • Save joshnesbitt/636293 to your computer and use it in GitHub Desktop.

Select an option

Save joshnesbitt/636293 to your computer and use it in GitHub Desktop.
module ExceptionCatcher
def with_exception_handling(silent=false, &block)
begin
yield block
rescue => e
unless silent
# send to hoptoad
puts "sending error somewhere"
end
raise e.class, e
end
end
end
class Example
include ExceptionCatcher
def do_something
with_exception_handling do
i_dont_exist
end
end
end
eg = Example.new
eg.do_something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment