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

suggestion: mark response validation errors#425

Open
bitcloud wants to merge 1 commit intoapigee-127:masterfrom
cospired:mark_response_validation
Open

suggestion: mark response validation errors#425
bitcloud wants to merge 1 commit intoapigee-127:masterfrom
cospired:mark_response_validation

Conversation

@bitcloud
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@bitcloud
Copy link
Copy Markdown
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