http-errors icon indicating copy to clipboard operation
http-errors copied to clipboard

Add "expose" to "new createError.[code || name]([msg]))" syntax

Open maneetgoyal opened this issue 4 years ago • 1 comments

Hi all,

Please consider add support for expose property in new createError.[code || name]([msg])) like syntax.

We use new createError.name([msg])) a lot because of its readability. It also mitigates the need to remember all those status codes. Being able to do something like below will be of great help.

var err = new createError.NotFound("Show this error to client.", {expose: true, ...});

maneetgoyal avatar May 21 '21 11:05 maneetgoyal

Thanks for the suggestion @maneetgoyal . This will be included in the upcoming 3.0 release as it provides an update to align to the new options feature of the global Error constructor.

dougwilson avatar Nov 15 '21 01:11 dougwilson