Skip to content

Commit 86637ec

Browse files
authored
ref(api): Rename handleXhrErrorResponse to getXhrErrorResponseHandler (#49100)
This renames `handleXhrErrorResponse` a) so that its name better reflects what it does, and b) as a preliminary step in changing how such responses are handled in a way that's backwards-compatible with `getsentry`. (Since it's a default export, changing the name in the file where it's defined doesn't affect `getsentry`, but it does make it so that when a similar change is made in `getsentry`, all of the names match.)
1 parent a75d826 commit 86637ec

File tree

14 files changed

+34
-34
lines changed

14 files changed

+34
-34
lines changed

static/app/actionCreators/project.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Client} from 'sentry/api';
33
import {t} from 'sentry/locale';
44
import ProjectsStore from 'sentry/stores/projectsStore';
55
import {Project} from 'sentry/types';
6-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
6+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
77

88
/**
99
* Fetches a project's details
@@ -21,7 +21,7 @@ export function fetchProjectDetails({
2121

2222
promise.then(ProjectsStore.onUpdateSuccess).catch(error => {
2323
const message = t('Unable to fetch project details');
24-
handleXhrErrorResponse(message)(error);
24+
getXhrErrorResponseHandler(message)(error);
2525
addErrorMessage(message);
2626
});
2727

static/app/actionCreators/savedSearches.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Client} from 'sentry/api';
22
import {MAX_AUTOCOMPLETE_RECENT_SEARCHES} from 'sentry/constants';
33
import {RecentSearch, SavedSearch, SavedSearchType} from 'sentry/types';
4-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
4+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
55

66
const getRecentSearchUrl = (orgSlug: string): string =>
77
`/organizations/${orgSlug}/recent-searches/`;
@@ -29,7 +29,7 @@ export function saveRecentSearch(
2929
},
3030
});
3131

32-
promise.catch(handleXhrErrorResponse('Unable to save a recent search'));
32+
promise.catch(getXhrErrorResponseHandler('Unable to save a recent search'));
3333

3434
return promise;
3535
}
@@ -61,7 +61,7 @@ export function fetchRecentSearches(
6161

6262
promise.catch(resp => {
6363
if (resp.status !== 401 && resp.status !== 403) {
64-
handleXhrErrorResponse('Unable to fetch recent searches')(resp);
64+
getXhrErrorResponseHandler('Unable to fetch recent searches')(resp);
6565
}
6666
});
6767

static/app/components/forms/controls/selectAsyncControl.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import debounce from 'lodash/debounce';
55
import {addErrorMessage} from 'sentry/actionCreators/indicator';
66
import {Client} from 'sentry/api';
77
import {t} from 'sentry/locale';
8-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
8+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
99

1010
import SelectControl, {ControlProps, GeneralSelectValue} from './selectControl';
1111

@@ -93,7 +93,7 @@ class SelectAsyncControl extends Component<SelectAsyncControlProps> {
9393
},
9494
err => {
9595
addErrorMessage(t('There was a problem with the request.'));
96-
handleXhrErrorResponse('SelectAsync failed')(err);
96+
getXhrErrorResponseHandler('SelectAsync failed')(err);
9797
// eslint-disable-next-line no-console
9898
console.error(err);
9999
}

static/app/components/modals/widgetBuilder/addToDashboardModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SelectControl from 'sentry/components/forms/controls/selectControl';
1717
import {t, tct} from 'sentry/locale';
1818
import {space} from 'sentry/styles/space';
1919
import {DateString, Organization, PageFilters, SelectValue} from 'sentry/types';
20-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
20+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
2121
import {MetricsCardinalityProvider} from 'sentry/utils/performance/contexts/metricsCardinality';
2222
import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
2323
import useApi from 'sentry/utils/useApi';
@@ -172,7 +172,7 @@ function AddToDashboardModal({
172172
addSuccessMessage(t('Successfully added widget to dashboard'));
173173
} catch (e) {
174174
const errorMessage = t('Unable to add widget to dashboard');
175-
handleXhrErrorResponse(errorMessage)(e);
175+
getXhrErrorResponseHandler(errorMessage)(e);
176176
addErrorMessage(errorMessage);
177177
}
178178
}

static/app/utils/customMeasurements/customMeasurementsProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilte
88
import {t} from 'sentry/locale';
99
import {Organization, PageFilters} from 'sentry/types';
1010
import {CustomMeasurementCollection} from 'sentry/utils/customMeasurements/customMeasurements';
11-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
11+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
1212
import useApi from 'sentry/utils/useApi';
1313

1414
import {
@@ -91,7 +91,7 @@ export function CustomMeasurementsProvider({
9191
const errorResponse =
9292
e?.responseJSON ?? t('Unable to fetch custom performance metrics');
9393
addErrorMessage(errorResponse);
94-
handleXhrErrorResponse(errorResponse)(e);
94+
getXhrErrorResponseHandler(errorResponse)(e);
9595
});
9696
}
9797

static/app/utils/handleXhrErrorResponse.spec.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Sentry from '@sentry/react';
22

3-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
3+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
44

55
describe('handleXhrErrorResponse', function () {
66
const stringError = {responseJSON: {detail: 'Error'}, status: 400};
@@ -13,23 +13,23 @@ describe('handleXhrErrorResponse', function () {
1313
});
1414

1515
it('does nothing if we have invalid response', function () {
16-
handleXhrErrorResponse('')(null);
16+
getXhrErrorResponseHandler('')(null);
1717
expect(Sentry.captureException).not.toHaveBeenCalled();
18-
handleXhrErrorResponse('')({});
18+
getXhrErrorResponseHandler('')({});
1919
expect(Sentry.captureException).not.toHaveBeenCalled();
2020
});
2121

2222
it('captures an exception to sdk when `resp.detail` is a string', function () {
23-
handleXhrErrorResponse('String error')(stringError);
23+
getXhrErrorResponseHandler('String error')(stringError);
2424
expect(Sentry.captureException).toHaveBeenCalledWith(new Error('String error'));
2525
});
2626

2727
it('captures an exception to sdk when `resp.detail` is an object', function () {
28-
handleXhrErrorResponse('Object error')(objError);
28+
getXhrErrorResponseHandler('Object error')(objError);
2929
expect(Sentry.captureException).toHaveBeenCalledWith(new Error('Object error'));
3030
});
3131
it('ignores `sudo-required` errors', function () {
32-
handleXhrErrorResponse('Sudo required error')({
32+
getXhrErrorResponseHandler('Sudo required error')({
3333
status: 401,
3434
responseJSON: {
3535
detail: {

static/app/utils/handleXhrErrorResponse.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/react';
22

33
import {ResponseMeta} from 'sentry/api';
44

5-
export default function handleXhrErrorResponse(message: string) {
5+
export default function getXhrErrorResponseHandler(message: string) {
66
return (resp: ResponseMeta) => {
77
if (!resp) {
88
return;

static/app/utils/releases/releasesProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Client} from 'sentry/api';
55
import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
66
import {t} from 'sentry/locale';
77
import {Organization, PageFilters, Release} from 'sentry/types';
8-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
8+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
99

1010
import useApi from '../useApi';
1111

@@ -78,7 +78,7 @@ function ReleasesProvider({
7878
const errorResponse = e?.responseJSON ?? t('Unable to fetch releases');
7979
addErrorMessage(errorResponse);
8080
setLoading(false);
81-
handleXhrErrorResponse(errorResponse)(e);
81+
getXhrErrorResponseHandler(errorResponse)(e);
8282
});
8383
return () => {
8484
shouldCancelRequest = true;

static/app/views/onboarding/onboarding.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {space} from 'sentry/styles/space';
2020
import {OnboardingSelectedSDK} from 'sentry/types';
2121
import {defined} from 'sentry/utils';
2222
import {trackAnalytics} from 'sentry/utils/analytics';
23-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
23+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
2424
import Redirect from 'sentry/utils/redirect';
2525
import testableTransition from 'sentry/utils/testableTransition';
2626
import useApi from 'sentry/utils/useApi';
@@ -248,7 +248,7 @@ function Onboarding(props: Props) {
248248
project_id: recentCreatedProject.id,
249249
});
250250
} catch (error) {
251-
handleXhrErrorResponse(t('Unable to delete project in onboarding'))(error);
251+
getXhrErrorResponseHandler(t('Unable to delete project in onboarding'))(error);
252252
// we don't give the user any feedback regarding this error as this shall be silent
253253
}
254254
}, [api, organization, recentCreatedProject, onboardingContext]);

static/app/views/onboarding/setupDocsLoader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {IconChevron} from 'sentry/icons';
1515
import {t} from 'sentry/locale';
1616
import {Organization, Project, ProjectKey} from 'sentry/types';
1717
import {trackAnalytics} from 'sentry/utils/analytics';
18-
import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
18+
import getXhrErrorResponseHandler from 'sentry/utils/handleXhrErrorResponse';
1919
import {decodeList} from 'sentry/utils/queryString';
2020
import useApi from 'sentry/utils/useApi';
2121
import {DynamicSDKLoaderOption} from 'sentry/views/settings/project/projectKeys/details/loaderSettings';
@@ -103,7 +103,7 @@ export function SetupDocsLoader({
103103
setProjectKeyUpdateError(false);
104104
} catch (error) {
105105
const message = t('Unable to updated dynamic SDK loader configuration');
106-
handleXhrErrorResponse(message)(error);
106+
getXhrErrorResponseHandler(message)(error);
107107
setProjectKeyUpdateError(true);
108108
}
109109
}, [api, location.query.product, organization.slug, project.slug, projectKey?.id]);

0 commit comments

Comments
 (0)