You can rescue for StandardError
, or simply rescue, which are the same:
rescue StandardError => e
# or
rescue => e
You can see in the following table which exceptions are rescued from StandardError
- Note that they are a subset from Exception
, and conceitually should be errors that are OK to be catch.
Of course you can have gems that defines exception in the wrong place, but this should not happen in well-developed gems.
(source: rubylearning.com)
I personally like to rescue only exceptions I know how to handle, except when it is to add in a log/backtrace system to consult the errors later. If this is the case, I usually rescue StandardError