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).
Like the other built-in custom response modules, the behavior of this method is customizable.
By default, it works as follows:
dataas JSON. If no
datais provided a default response body will be sent (the string
"Internal Server Error").
views/500.ejs(assuming the default EJS view engine). If no such view is found, or an error occurs attempting to serve it, a default response body will be sent with the string
"Internal Server Error".
return res.serverError('Salesforce could not be reached');
- This method is terminal, meaning it is generally the last line of code your app should run for a given request (hence the advisory usage of
returnthroughout 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.jsresponse method does not exist in your app, Sails will implicitly use the default behavior. +The specified
datawill 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').