use portainer errors for mapped functions
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { useQuery } from 'react-query';
|
||||
|
||||
import PortainerError from '@/portainer/error';
|
||||
import axios from '@/portainer/services/axios';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
|
||||
@@ -23,6 +22,6 @@ export async function getIsRBACEnabled(environmentId: EnvironmentId) {
|
||||
);
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw new PortainerError('Unable to check if RBAC is enabled.', e as Error);
|
||||
throw parseAxiosError(e, 'Unable to check if RBAC is enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useQuery } from 'react-query';
|
||||
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import PortainerError from '@/portainer/error';
|
||||
import axios from '@/portainer/services/axios';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
|
||||
import { IngressControllerClassMap } from './types';
|
||||
@@ -61,7 +60,7 @@ export async function getIngressControllerClassMap({
|
||||
);
|
||||
return controllerMaps;
|
||||
} catch (e) {
|
||||
throw new PortainerError('Unable to get ingress controllers.', e as Error);
|
||||
throw parseAxiosError(e, 'Unable to get ingress controllers.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +76,7 @@ export async function updateIngressControllerClassMap(
|
||||
>(buildUrl(environmentId, namespace), ingressControllerClassMap);
|
||||
return controllerMaps;
|
||||
} catch (e) {
|
||||
throw new PortainerError(
|
||||
'Unable to update ingress controllers.',
|
||||
e as Error
|
||||
);
|
||||
throw parseAxiosError(e, 'Unable to update ingress controllers.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,7 +128,7 @@ async function getConfigMapsForCluster(
|
||||
);
|
||||
return configMaps.flat();
|
||||
} catch (e) {
|
||||
throw parseKubernetesAxiosError(e, 'Unable to retrieve ConfigMaps');
|
||||
throw new PortainerError('Unable to retrieve ConfigMaps', e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -123,10 +124,7 @@ async function getSecretsForCluster(
|
||||
);
|
||||
return secrets.flat();
|
||||
} catch (e) {
|
||||
throw parseKubernetesAxiosError(
|
||||
e as Error,
|
||||
'Unable to retrieve secrets for cluster'
|
||||
);
|
||||
throw new PortainerError('Unable to retrieve secrets for cluster', e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user