2023-07-17 11:27:27 +00:00
|
|
|
let UserError = require('vn-loopback/util/user-error');
|
|
|
|
|
|
|
|
module.exports = Self => {
|
|
|
|
Self.rewriteDbError(function(err) {
|
2023-07-17 12:07:45 +00:00
|
|
|
console.log(err);
|
2023-07-17 11:51:16 +00:00
|
|
|
if (err.code === 'ER_ROW_IS_REFERENCED_2')
|
2023-07-17 11:27:27 +00:00
|
|
|
return new UserError(`This invoice has a linked vehicle.`);
|
|
|
|
return err;
|
|
|
|
});
|
|
|
|
};
|