You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
planka_custom/server/api/responses/serverError.js

37 lines
594 B
JavaScript

/**
* serverError.js
*
* A custom response.
*
* Example usage:
* ```
* return res.serverError();
* // -or-
* return res.serverError(optionalData);
* ```
*
* Or with actions2:
* ```
* exits: {
* somethingHappened: {
* responseType: 'serverError'
* }
* }
* ```
*
* ```
* throw 'somethingHappened';
* // -or-
* throw { somethingHappened: optionalData }
* ```
*/
module.exports = function serverError(message) {
const { res } = this;
return res.status(500).json({
code: 'E_SERVER_ERROR',
message,
});
};