Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows keeping response errors in production mode with sails.config.keepResponseErrors #2853

Merged
merged 1 commit into from
Apr 24, 2015

Conversation

alivesay
Copy link
Contributor

IMHO the current behavior in response handlers of clearing the body in production mode should be optional, hence the proposed sails.config.keepResponseErrors here.

Consider the case of a waterline validation error from a model backing a REST operation, one could return a 400 with a list of validation failures:

if (err && err.code === 'E_VALIDATION') {
  return res.badRequest(err.invalidAttributes);
}

The docs here for res.badRequest() say "For requesters expecting JSON, this response includes the 400 status code and any relevant data sent as validationErrors." Well, this isn't true -- in production mode response body is cleared regardless of req.wantsJSON.

Thoughts?

@jpwilliams
Copy link

+1. I'd love this functionality.

@sgress454
Copy link
Member

Looks good, thanks Andrew! Would you mind adding some docs for it here?

sgress454 added a commit that referenced this pull request Apr 24, 2015
Allows keeping response errors in production mode with sails.config.keepResponseErrors
@sgress454 sgress454 merged commit 71f96b8 into balderdashy:master Apr 24, 2015
alivesay added a commit to alivesay/sails-docs that referenced this pull request Apr 24, 2015
@alivesay
Copy link
Contributor Author

Done. Thanks all.

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

Successfully merging this pull request may close these issues.

5 participants