In a current project I ended up writing the code below (relevant part is
the last rescue statement):
def perform_single_request(conn = init_connection)
self.last_status = 'started'
response = http_call_with_retries(conn)
# Error types that we're allowed to **believe** they're transient. We
# to save current request state, so that the next time it runs,
# it will continue from where it was.
rescue Faraday::Error::ClientError, SyncEngine::Error::RateLimitExceeded
rescue SyncEngine::Error::Base => e
* rescue Exception => e # We don't want another exception to be raised.
Here we will # *try* to finish the execution as clean as possible, but
in any case # what we want is the original exception to be re-raised,
not a different # one. begin errback(e) clear_pagination
save! rescue Exception end raise e end*
Do you think this is a legit use of rescue Exception? I'm a aware of some
of the issues with it, but now I'm wondering if there may be cases that
could make such code critical or dangerous.
What would be legit uses of rescue Exception?