Edit Page

res.serverError()

This method is used to send a 500 ("Server Error") response back down to the client, indicating that some kind of server error occurred (i.e. the error is not the requesting user agent's fault).

Usage

#
return res.serverError(err);

Or:

Details

#

Like the other built-in custom response modules, the behavior of this method is customizable.

By default, it works as follows:

Example

#
return res.serverError('Salesforce could not be reached');

Notes

#
  • This method is terminal, meaning that it is generally the last line of code your app should run for a given request (hence the advisory usage of return throughout these docs).
  • res.serverError() (like other userland response methods) can be overridden or modified. It runs the response method defined in api/responses/serverError.js. If a serverError.js response method does not exist in your app, Sails will use the default behavior.
  • The specified data will be excluded from the JSON response and view locals if the app is running in the "production" environment (i.e. process.env.NODE_ENV === 'production').

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

Reference