Skip to content

Commit

Permalink
fix: return safe error (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-envoy authored Jun 29, 2023
1 parent 162234f commit 5721bec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 9 additions & 3 deletions src/util/axiosConstructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5721bec

Please sign in to comment.