From 5721bec309ce2478ae5ca437a10b5df0264cf0a2 Mon Sep 17 00:00:00 2001 From: ahmed-envoy <96131446+ahmed-envoy@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:11:35 -0400 Subject: [PATCH] fix: return safe error (#34) --- package.json | 2 +- src/util/axiosConstructor.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 19e4264..64b0529 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@envoy/envoy-integrations-sdk", - "version": "2.0.0-beta.26", + "version": "2.0.0-beta.27", "description": "SDK for building Envoy integrations.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/util/axiosConstructor.ts b/src/util/axiosConstructor.ts index efaf533..cd5774a 100644 --- a/src/util/axiosConstructor.ts +++ b/src/util/axiosConstructor.ts @@ -5,9 +5,15 @@ export function createAxiosClient(config?: AxiosRequestConfig | undefined): Axio client.interceptors.response.use((response) => { return response; }, (error) => { - delete error.config?.headers; - delete error.config?.proxy; - return Promise.reject(error); + const safeError = { + code: error.code, + message: error.message, + name: error.name, + baseURL: error.request?.baseURL ?? error.config?.baseURL, + url: error.request?.url ?? error.config?.url, + method: error.request?.method ?? error.config?.method, + } + return Promise.reject(safeError); }); return client;