Rescue from system-level exceptions and allow rails testing code to finalize before rethrowing
In https://ops.gitlab.net/gitlab-com/database-team/gitlab-com-database-testing/-/pipelines/1005117/failures, a migration threw a SystemStackError
, which isn't caught by our rescue StandardError => e
here. The json writer couldn't finalize, so this caused a truncated json file that broke the notifier.
We should change this to rescue Exception => e
to catch more fundamental code problems such as syntax errors and stack overflows. We always rethrow the exception after cleaning up our instrumentation, so it's safe to catch these errors.