Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,28 @@ function checkResponseStatus(response) {
: `Server responded with error (${response.status}): ${response.url}`;
const err = new Error(errorMessage);
err.response = response;
response.json().then((jsonResponse) => {
Sentry.captureException(err, {
extra: {
url: response.url,
status: response.status,
responseBody: jsonResponse,
}
});
}).catch(() => {
// If response body is not JSON, capture exception without response body
Sentry.captureException(err, {
extra: {
url: response.url,
status: response.status,
responseBody: 'Unable to parse response body as JSON',
}

// Don't log 404 errors to Sentry as they're often expected (non-existent resources)
if (response.status !== 404) {
response.json().then((jsonResponse) => {
Sentry.captureException(err, {
extra: {
url: response.url,
status: response.status,
responseBody: jsonResponse,
}
});
}).catch(() => {
// If response body is not JSON, capture exception without response body
Sentry.captureException(err, {
extra: {
url: response.url,
status: response.status,
responseBody: 'Unable to parse response body as JSON',
}
});
});
});
}
throw err;
}
}
Expand Down
Loading