diff --git a/clients/withManifest.ts b/clients/withManifest.ts index bf6d66ebc..7525fcfae 100644 --- a/clients/withManifest.ts +++ b/clients/withManifest.ts @@ -158,18 +158,22 @@ const fetchWithProps = async ( return response.json(); } - console.error(init?.body, response); - const error = await response.text(); + const errorBody = await response.text(); + const correlationId = response.headers.get("x-correlation-id"); + console.error( + `Invoke error ${response.status} ${response.statusText} - ${url}`, + errorBody, + ); if (response.headers.get("content-type") === "application/json") { - const errorObj = JSON.parse(error); + const errorObj = JSON.parse(errorBody); throw new InvokeError(`${response.status}: ${response.statusText}`, { cause: errorObj, - correlationId: response.headers.get("x-correlation-id"), + correlationId, }); } throw new InvokeError(`${response.status}: ${response.statusText}`, { - cause: error, - correlationId: response.headers.get("x-correlation-id"), + cause: errorBody, + correlationId, }); }; diff --git a/utils/fetchAPI.ts b/utils/fetchAPI.ts index 218025ecb..54dd1465b 100644 --- a/utils/fetchAPI.ts +++ b/utils/fetchAPI.ts @@ -14,6 +14,10 @@ export const fetchAPI = async ( return response.json(); } - console.error(input, response); + const errorBody = await response.text(); + console.error( + `fetchAPI error ${response.status} ${response.statusText} - ${input}`, + errorBody, + ); throw new Error(`fetch ${input} responded with status ${response.status}`); };