const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { require('../methods/supplier/supplier-dms/removeFile')(Self); require('../methods/supplier/supplier-dms/downloadFile')(Self); require('../methods/supplier/supplier-dms/uploadFile')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`The file is already attached to another entry`); return err; }); };