1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

fix(kubeapi): fix ts api error handling [EE-5558] (#10488)

* fix(kubeapi): fix ts api error handling [EE-5558]

* use portainer errors for mapped functions

* don't parse long patch responses

* allow nested kube error that's thrown to bubble up

---------

Co-authored-by: testa113 <testa113>
This commit is contained in:
Ali 2023-10-23 20:52:40 +01:00 committed by GitHub
parent 6c55cac52a
commit 96ead31a8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 210 additions and 234 deletions

View file

@ -10,6 +10,7 @@ import {
} from '@/portainer/services/notifications';
import { isFulfilled, isRejected } from '@/portainer/helpers/promise-utils';
import { pluralize } from '@/portainer/helpers/strings';
import PortainerError from '@/portainer/error';
import { parseKubernetesAxiosError } from '../axiosError';
@ -127,10 +128,7 @@ async function getConfigMapsForCluster(
);
return configMaps.flat();
} catch (e) {
throw parseKubernetesAxiosError(
e as Error,
'Unable to retrieve ConfigMaps for cluster'
);
throw new PortainerError('Unable to retrieve ConfigMaps', e);
}
}
@ -142,10 +140,7 @@ async function getConfigMaps(environmentId: EnvironmentId, namespace: string) {
);
return data.items;
} catch (e) {
throw parseKubernetesAxiosError(
e as Error,
'Unable to retrieve ConfigMaps'
);
throw parseKubernetesAxiosError(e, 'Unable to retrieve ConfigMaps');
}
}
@ -157,7 +152,7 @@ async function deleteConfigMap(
try {
await axios.delete(buildUrl(environmentId, namespace, name));
} catch (e) {
throw parseKubernetesAxiosError(e as Error, 'Unable to remove ConfigMap');
throw parseKubernetesAxiosError(e, 'Unable to remove ConfigMap');
}
}