Skip to content

Commit

Permalink
fix(aco): handling a missing method error
Browse files Browse the repository at this point in the history
  • Loading branch information
vitshev committed Feb 14, 2024
1 parent e51667a commit 2ca1b02
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {Action} from 'redux';
import {ThunkAction} from 'redux-thunk';
import {Toaster} from '@gravity-ui/uikit';
import type {AxiosError} from 'axios';
import {YTApiId, ytApiV4Id} from '../../../../rum/rum-wrap-api';
import {getQueryTrackerRequestOptions} from '../query/selectors';
import {QUERY_ACO_LOADING} from './constants';
import type {ActionD} from '../../../../types';
import {showErrorPopup} from '../../../../utils/utils';
import type {QueryACOState} from './reducer';

export type QueryACOLoadingAction = Action<typeof QUERY_ACO_LOADING.REQUEST>;
Expand All @@ -25,6 +27,24 @@ export const getQueryACO = (): ThunkAction<Promise<unknown>, any, any, any> => {

return ytApiV4Id
.getQueryTrackerInfo(YTApiId.getQueryTrackerInfo, {
setup: {
transformError({
parsedData,
rawError,
}: {
parsedData: Awaited<ReturnType<typeof ytApiV4Id.getQueryTrackerInfo>>;
rawError: AxiosError;
}) {
if (rawError?.response?.status === 404) {
throw {
data: parsedData,
status: rawError?.response?.status,
};
}

throw parsedData;
},
},
parameters: {stage},
})
.then((data) => {
Expand All @@ -35,13 +55,14 @@ export const getQueryACO = (): ThunkAction<Promise<unknown>, any, any, any> => {
})
.catch((error) => {
// @todo Remove the condition when the method will be implemented on all clusters
if (error?.message !== 'Malformed command name') {
if (error?.status !== 404) {
const toaster = new Toaster();
toaster.add({
name: 'aco',
type: 'error',
title: 'Failed to load ACO',
content: error?.message,
actions: [{label: ' Details', onClick: () => showErrorPopup(error)}],
});
}

Expand Down

0 comments on commit 2ca1b02

Please # to comment.