From e82fc2b667adac7529459ef4065b7ade5a90355b Mon Sep 17 00:00:00 2001 From: Akalanka Date: Thu, 8 Feb 2024 22:30:22 +0530 Subject: [PATCH] Patch(service-connector): header interceptor failure log --- packages/service-connector/src/index.js | 9 ++++++++- packages/service-connector/test/index.test.js | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/service-connector/src/index.js b/packages/service-connector/src/index.js index ced859b..b7277a7 100644 --- a/packages/service-connector/src/index.js +++ b/packages/service-connector/src/index.js @@ -20,7 +20,14 @@ const serviceConnector = ({ service, headerIntercepts, loggable, logs = true, .. if (headerIntercepts) { let intercepts = headerIntercepts(config); if (intercepts instanceof Promise) - intercepts = await intercepts.catch((e) => logger.error("Failed to intercept headers", e?.message)); + intercepts = await intercepts.catch((e) => + logger.error( + `Failed to intercept headers - ${coloredString("method")}: ${coloredString( + config.method + )} - ${coloredString("url")}: ${coloredString(`${config.baseURL ?? ""}${config.url}`, "url-value")}`, + e?.message + ) + ); config.headers = { ...config.headers, ...intercepts diff --git a/packages/service-connector/test/index.test.js b/packages/service-connector/test/index.test.js index 498dede..b94f0d0 100644 --- a/packages/service-connector/test/index.test.js +++ b/packages/service-connector/test/index.test.js @@ -97,7 +97,12 @@ describe("service-connector", () => { }); const response = await asyncInterceptedConnector.get("/"); expect(response.status).toEqual(200); - expect(mockLogger.error).toBeCalledWith(`Failed to intercept headers`, undefined); + expect(mockLogger.error).toBeCalledWith( + `Failed to intercept headers - ${coloredString("method")}: ${coloredString("get")} - ${coloredString( + "url" + )}: ${coloredString("https://google.com/", "url-value")}`, + undefined + ); }); });