Skip to content

fix(types): add responseTime to customErrorMessage callback - #372

Open
vikasrathod4299 wants to merge 4 commits into
pinojs:masterfrom
vikasrathod4299:fix-issue-318-customErrorMessage-type
Open

fix(types): add responseTime to customErrorMessage callback#372
vikasrathod4299 wants to merge 4 commits into
pinojs:masterfrom
vikasrathod4299:fix-issue-318-customErrorMessage-type

Conversation

@vikasrathod4299

Copy link
Copy Markdown

Fixes #359

Updated the customErrorMessage type definition to include the 4th argument responseTime.

This allows users to make full use of all parameters passed to customErrorMessage.

  • Updated Options interface in index.d.ts
  • Added test case to index.test-d.ts using 4 parameters

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread index.test-d.ts Outdated
@@ -48,6 +48,9 @@ pinoHttp<CustomRequest, CustomResponse>({ customSuccessMessage: (req: CustomRequ
// #customErrorMessage
pinoHttp({ customErrorMessage: (req: IncomingMessage, res: ServerResponse, error: Error) => `Error - ${error}` });

@lokeshwar777 lokeshwar777 Jul 30, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of overwriting the whole prop you could update the existing config (line 49) to include customErrorMessage with responseTime (avoids redundancy and looks clean) 🙂

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested. Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: customErrorMessage actually got passed 4 arguments, but it's ts declaration only has 3 arguments

3 participants