expressjs / api-error-handler

Express error handlers for JSON APIs
MIT License
101 stars 23 forks source link

add showStack option #13

Open jonchurch opened 4 years ago

jonchurch commented 4 years ago

This feature has been requested a few times and attempted in several PRs such as:

1 #2 #5 #12

Most recently something like this was requested in #11

I read the feedback from other PRs and created one that I think accomplishes the requests I saw there, such as setting the option as a boolean.

While working on this I realized that the production flag internally in the module is set at the time of require, which necessitated some tricky work in the tests. I created two new sets of tests for regression testing of this feature. They clear the require cache for this module before setting the NODE_ENV value, so we can properly test the behavior of hiding/showing stack traces based on the environment.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 947935243f2d2f4591e81f7b0145e12fc2bbcac6 on jonchurch:show-stack-option into df765a50c0c1de4fdbe4ce9cef2d910df4d8ba3e on expressjs:master.