Commit 1d11249b authored by allison.browne's avatar allison.browne

For ProjectErrorTrackingSettings Rescue All Errors

For StandardError rescue and return a json error to avoid
cache becoming un-reactive which causes an infinite spinner
parent 9be8964c
...@@ -122,6 +122,9 @@ module ErrorTracking ...@@ -122,6 +122,9 @@ module ErrorTracking
{ error: e.message, error_type: SENTRY_API_ERROR_INVALID_SIZE } { error: e.message, error_type: SENTRY_API_ERROR_INVALID_SIZE }
rescue Sentry::Client::BadRequestError => e rescue Sentry::Client::BadRequestError => e
{ error: e.message, error_type: SENTRY_API_ERROR_TYPE_BAD_REQUEST } { error: e.message, error_type: SENTRY_API_ERROR_TYPE_BAD_REQUEST }
rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e)
{ error: 'Unexpected Error' }
end end
# http://HOST/api/0/projects/ORG/PROJECT # http://HOST/api/0/projects/ORG/PROJECT
......
...@@ -138,8 +138,6 @@ describe ErrorTracking::ProjectErrorTrackingSetting do ...@@ -138,8 +138,6 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
error: 'error message', error: 'error message',
error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE
) )
expect(subject).to have_received(:sentry_client)
expect(sentry_client).to have_received(:list_issues)
end end
end end
...@@ -159,8 +157,6 @@ describe ErrorTracking::ProjectErrorTrackingSetting do ...@@ -159,8 +157,6 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
error: 'Sentry API response is missing keys. key not found: "id"', error: 'Sentry API response is missing keys. key not found: "id"',
error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_MISSING_KEYS error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_MISSING_KEYS
) )
expect(subject).to have_received(:sentry_client)
expect(sentry_client).to have_received(:list_issues)
end end
end end
...@@ -181,8 +177,21 @@ describe ErrorTracking::ProjectErrorTrackingSetting do ...@@ -181,8 +177,21 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
error: error_msg, error: error_msg,
error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_INVALID_SIZE error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_INVALID_SIZE
) )
expect(subject).to have_received(:sentry_client) end
expect(sentry_client).to have_received(:list_issues) end
context 'when sentry client raises StandardError' do
let(:sentry_client) { spy(:sentry_client) }
before do
synchronous_reactive_cache(subject)
allow(subject).to receive(:sentry_client).and_return(sentry_client)
allow(sentry_client).to receive(:list_issues).with(opts).and_raise(StandardError)
end
it 'returns error' do
expect(result).to eq(error: 'Unexpected Error')
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment