2024-05-16 08:23:33 +00:00
|
|
|
const UserError = require('vn-loopback/util/user-error');
|
|
|
|
module.exports = Self => {
|
|
|
|
Self.rewriteDbError(function(err) {
|
|
|
|
if (err.code === 'ER_DUP_ENTRY')
|
|
|
|
return new UserError(`This PDA is already assigned to another user`);
|
2024-05-21 17:25:18 +00:00
|
|
|
|
|
|
|
if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA')
|
2024-05-23 10:23:31 +00:00
|
|
|
return new UserError(err.sqlMessage);
|
2024-05-16 08:23:33 +00:00
|
|
|
return err;
|
|
|
|
});
|
|
|
|
};
|