const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { require('../methods/department/getLeaves')(Self); require('../methods/department/nodeAdd')(Self); require('../methods/department/nodeDelete')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_ROW_IS_REFERENCED_2') return new UserError(`You cannot remove this department`); if (err.code === 'ER_DUP_ENTRY') return new UserError(`The department name can't be repeated`); return err; }); };