Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Medic
exam-sso-api
Commits
13202b61
Commit
13202b61
authored
Jul 05, 2019
by
Lorex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增伺服器錯誤處理
parent
58b973bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
src/api/responses/serverError.js
src/api/responses/serverError.js
+38
-0
No files found.
src/api/responses/serverError.js
0 → 100644
View file @
13202b61
/**
* 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
}
`
});
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment