How to "ignore" caught exceptions?
exception, ruby
Solution
This is called "exception swallowing". You intercept an exception and don't do anything with it.
begin
# do some dangerous stuff, like running test scripts
rescue => ex
# do nothing here, except for logging, maybe
end
If you do not need to do anything with the exception, you can omit the `=> ex`:
begin
# do some dangerous stuff, like running test scripts
rescue; end
If you need to rescue Exceptions that don't subclass from `StandardError`, you need to be more explicit:
begin
# do some dangerous stuff, like running test scripts
rescue Exception
# catches EVERY exception
end
Problem
I use rufus scheduler to run overnight test scripts by calling my functions. Sometimes I can see "scheduler caught exception:" a message that threw some of my functions. Then scheduler stops execution of following test cases. How can I make it so scheduler runs all test cases regardless of any exception caught?