Skip to content

feat(types): add responseTime parameter to customErrorMessage#358

Open
MarcusHong wants to merge 1 commit intopinojs:masterfrom
MarcusHong:type-add
Open

feat(types): add responseTime parameter to customErrorMessage#358
MarcusHong wants to merge 1 commit intopinojs:masterfrom
MarcusHong:type-add

Conversation

@MarcusHong
Copy link
Copy Markdown

Description

Add responseTime parameter to customErrorMessage type definition to allow access to the request's response time when creating custom error messages.

Changes

  • Updated TypeScript type definition for customErrorMessage to include responseTime parameter
  • Response time is provided in milliseconds, consistent with pino-http's existing timing

Example Usage

const logger = pinoHttp({
  customErrorMessage: (req, res, err, responseTime) => {
    return `${err.message} (took ${responseTime}ms)`;
  }
});

@mcollina
Copy link
Copy Markdown
Member

Thanks for opening a PR! Can you please add a unit test? We use tsd for the types

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.

2 participants