api-error-handler icon indicating copy to clipboard operation
api-error-handler copied to clipboard

Newoptions

Open dankahle opened this issue 10 years ago • 5 comments

I thought this would be a nice way to handle the "stack" issue. I.e. you were already thinking about making the stack optional, but in reality, it's something they may or may not want for specific environments. If you let them pass that in, in a comma separated list, then they can shut down the stack where they want. By default it's always on, and off for production. I added an empty string option as well (always show the stack), as when I got to thinking about it, they might think that would do what you'd expect, always show the stack.

dankahle avatar Mar 26 '15 17:03 dankahle

Sorry bout the diffs, I was copying code back and forth between the npm installed version, must have had different line endings or something.

dankahle avatar Mar 26 '15 17:03 dankahle

Sorry accidently closed it. Was wondering what the "closed and comment" button did, now I know :).

dankahle avatar Mar 26 '15 18:03 dankahle

Can't tell what the diff is. Can you undo spacing styles?

jonathanong avatar Mar 26 '15 18:03 jonathanong

This whole thing is super smelly. Just add a option that is '{stack: true}or{stack: false}` and thus you can perform any environment-based logic you like.

dougwilson avatar Mar 26 '15 18:03 dougwilson

I was trying to gracefully handle the following situation:

var showStack = true; if(process.env.NODE_ENV == 'production' || process.env.NODE_ENV == 'staging') showStack = false;

app.use(apiErrorHandler({stack: showStack}))

with something like this instead:

app.use(apiErrorHandler({noStackEnvs: 'production, staging'}))

the code was already in there for checking the env, using that to determine whether to show stack or not, just figured it could check more than one then.

On Thu, Mar 26, 2015 at 11:28 AM, Douglas Christopher Wilson < [email protected]> wrote:

This whole thing is super smelly. Just add a option that is '{stack: true} or{stack: false}` and thus you can perform any environment-based logic you like.

— Reply to this email directly or view it on GitHub https://github.com/expressjs/api-error-handler/pull/1#issuecomment-86658059 .

dankahle avatar Mar 26 '15 18:03 dankahle