Commit 13202b61 authored by Lorex's avatar Lorex
Browse files

feat: 新增伺服器錯誤處理

parent 58b973bb
/**
* Module dependencies
*/
var _ = require('@sailshq/lodash');
/**
* 500 (Server Error) Response
*
* Usage:
* return res.serverError();
* return res.serverError(err);
* return res.serverError(err, 'some/specific/error/view');
*
* NOTE:
* If something throws in a policy or controller, or an internal
* error is encountered, Sails will call `res.serverError()`
* automatically.
*/
module.exports = function serverError(data) {
// Get access to `req` and `res`
var req = this.req;
var res = this.res;
// Get access to `sails`
var sails = req._sails;
// Define the status code to send in the response.
// Set status code
res.status(500).send({success: false, msg: `伺服器錯誤:${data}`});
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment