const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { require('../methods/stock-bought/getStockBought')(Self); require('../methods/stock-bought/getStockBoughtDetail')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`This buyer has already made a reservation for this date`); return err; }); };