I've just found that you can use rescue like you can with if and unless
x = (do_something_that_might_raise rescue nil)
x will be nil if do_something_that_might_raise raises an exception... Obviously catching and swallowing all exceptions from isn't great but it does have it's uses :)
The parentheses are actually not needed, try it out!
ReplyDelete