expressjs / csurf

CSRF token middleware
MIT License
2.3k stars 216 forks source link

Option to pass errors the connect way. #88

Closed VandorpeDavid closed 8 years ago

VandorpeDavid commented 8 years ago

Use next(err) instead of throw err when the developer prefers this behavior. Fixes #78 .

To enable this behavior, set options.throwErrors to false.

dougwilson commented 8 years ago

Hi @VandorpeDavid, thank you for the pull request! There is nothing inherently wrong with throwing in the base function, as middleware are expected to be within a try catch block. Otherwise, I think changing it to next(err) is easy enough. I don't think we need to preserve the current behavior, and should just classify this as a bug.