Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#OBS-I285: fix: Logging errors in the middleware #263

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api-service/src/helpers/ResponseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import moment from "moment";
import _ from "lodash";
import { ObsrvError } from "../types/ObsrvError";
import logger from "../logger";

const ResponseHandler = {
successResponse: (req: Request, res: Response, result: Result) => {
Expand All @@ -26,6 +27,8 @@

errorResponse: (error: Record<string, any>, req: Request, res: Response) => {
const { statusCode, message, errCode, code = "INTERNAL_SERVER_ERROR", trace = "" } = error;
const sanitizedError = { ...error, proxyAuthKey: "REDACTED" };
logger.error(sanitizedError)

Check failure on line 31 in api-service/src/helpers/ResponseHandler.ts

View workflow job for this annotation

GitHub Actions / test-cases

Mixed spaces and tabs
Fixed Show fixed Hide fixed
const { id, entity, body } = req as any;
const msgid = _.get(body, ["params", "msgid"])
const resmsgid = _.get(res, "resmsgid")
Expand All @@ -37,6 +40,8 @@

obsrvErrorResponse: (error: ObsrvError, req: Request, res: Response) => {
const { statusCode, message, errCode, code = "INTERNAL_SERVER_ERROR", data } = error;
const sanitizedError = { ...error, proxyAuthKey: "REDACTED" };
logger.error(sanitizedError)

Check failure on line 44 in api-service/src/helpers/ResponseHandler.ts

View workflow job for this annotation

GitHub Actions / test-cases

Mixed spaces and tabs
const { id, entity, body } = req as any;
const msgid = _.get(body, ["params", "msgid"])
const resmsgid = _.get(res, "resmsgid")
Expand Down
Loading