Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Conversation

bitcloud
Copy link
Contributor

As input errors generate a different response code and are handled differently, make it easy to distinguish them from another by adding
err.responseValidation = true
to the error object.

This allows to simply do something like this:

if(err.failedValidation) {
  if(err.responseValidation) {
    res.statusCode = 500;
    res.end("Internal Error");
  } else {
    res.statusCode = 400;
    res.end("Input Error");
  }
}

@whitlockjc
Copy link
Member

Well, you could check for the existence of the originalResponse property but I'm not sure that's publicized. Let me think.

@bitcloud
Copy link
Contributor Author

this only works if the originalRespons is not undefined.
been there done that :)

@bitcloud
Copy link
Contributor Author

Any updates here? :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants