2021-06-28 11:30:49 +00:00
|
|
|
const UserError = require('vn-loopback/util/user-error');
|
|
|
|
|
2019-06-06 11:59:11 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
require('../methods/ticket-dms/removeFile')(Self);
|
2021-06-28 11:30:49 +00:00
|
|
|
|
|
|
|
Self.rewriteDbError(function(err) {
|
|
|
|
if (err.code === 'ER_DUP_ENTRY')
|
|
|
|
return new UserError('This document already exists on this ticket');
|
|
|
|
return err;
|
|
|
|
});
|
2019-06-06 11:59:11 +00:00
|
|
|
};
|