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

fix(errors): surface react docker errors to front end [EE-7053] (#11726)

Co-authored-by: testa113 <testa113>
This commit is contained in:
Ali 2024-05-13 15:34:00 +12:00 committed by GitHub
parent 55667a878a
commit 6b5a402962
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 107 additions and 142 deletions

View file

@ -1,5 +1,4 @@
import { EndpointSettings } from 'docker-types/generated/1.41';
import { RawAxiosRequestHeaders } from 'axios';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
@ -11,6 +10,7 @@ import {
} from '@/react-tools/react-query';
import { queryKeys as dockerQueryKeys } from '../../queries/utils';
import { addNodeHeader } from '../../proxy/addNodeHeader';
import { buildUrl } from './buildUrl';
@ -56,18 +56,15 @@ export async function connectContainer({
};
}
const headers: RawAxiosRequestHeaders = {};
if (nodeName) {
headers['X-PortainerAgent-Target'] = nodeName;
}
const headers = addNodeHeader(nodeName);
try {
await axios.post(
buildUrl(environmentId, { id: networkId, action: 'connect' }),
payload
payload,
{ headers }
);
} catch (err) {
throw parseAxiosError(err as Error, 'Unable to connect container');
throw parseAxiosError(err, 'Unable to connect container');
}
}

View file

@ -54,6 +54,6 @@ export async function getNetworks(
network.Attachable === true)
);
} catch (err) {
throw parseAxiosError(err as Error, 'Unable to retrieve networks');
throw parseAxiosError(err, 'Unable to retrieve networks');
}
}