This middleware makes Bugsnag ignore network connection errors raised from Sidekiq jobs. Instead of reporting errors to Bugsnag every time the job retries, we only report these errors if/when the job finally dies. The goal is to eliminate extra noise caused by transient network errors.
class BugsnagSidekiqDeathHandler
def self.handler
->(_job, exception) do
# The <= operator returns true if the class on the left is the same as OR a subclass of the class on the right
if BugsnagSidekiqMiddleware::IGNORED_EXCEPTIONS.any? { |e| exception.class <= e }