wikijs-fork/server/helpers/graph.js

22 lines
507 B
JavaScript
Raw Normal View History

const _ = require('lodash')
module.exports = {
generateSuccess (msg) {
return {
succeeded: true,
errorCode: 0,
slug: 'ok',
message: _.defaultTo(msg, 'Operation succeeded.')
}
},
generateError (err, complete = true) {
const error = {
succeeded: false,
2019-06-05 02:23:32 +00:00
errorCode: _.isFinite(err.code) ? err.code : 1,
slug: err.name,
message: err.message || 'An unexpected error occured.'
}
return (complete) ? { responseResult: error } : error
}
}