Browse Source

fix(API): Fix usage of `getXhrErrorResponseHandler` (#49119)

This fixes two places where we've been using `getXhrErrorResponseHandler` wrong, either passing it a JSON object rather than an error message (leading to `Error: [object Object]` events in Sentry) or failing the call the handler it returns.
Katie Byers 1 year ago
parent
commit
af07305612

+ 1 - 2
static/app/utils/customMeasurements/customMeasurementsProvider.tsx

@@ -88,8 +88,7 @@ export function CustomMeasurementsProvider({
             return;
           }
 
-          const errorResponse =
-            e?.responseJSON ?? t('Unable to fetch custom performance metrics');
+          const errorResponse = t('Unable to fetch custom performance metrics');
           addErrorMessage(errorResponse);
           getXhrErrorResponseHandler(errorResponse)(e);
         });

+ 1 - 1
static/app/utils/releases/releasesProvider.tsx

@@ -75,7 +75,7 @@ function ReleasesProvider({
           return;
         }
 
-        const errorResponse = e?.responseJSON ?? t('Unable to fetch releases');
+        const errorResponse = t('Unable to fetch releases');
         addErrorMessage(errorResponse);
         setLoading(false);
         getXhrErrorResponseHandler(errorResponse)(e);

+ 2 - 2
static/app/views/settings/projectIssueGrouping/upgradeGrouping.tsx

@@ -88,8 +88,8 @@ function UpgradeGrouping({
       clearIndicators();
       ProjectsStore.onUpdateSuccess(response);
       onUpgrade();
-    } catch {
-      getXhrErrorResponseHandler(t('Unable to upgrade config'));
+    } catch (err) {
+      getXhrErrorResponseHandler(t('Unable to upgrade config'))(err);
     }
   }