不要怂,就是干,撸起袖子干!

Commit 57dfc730 by Victor Pontis

make regex parsing more lenient

1 parent 3cd0f893
Showing with 16 additions and 10 deletions
......@@ -253,16 +253,22 @@ module.exports = (function() {
});
case '23505':
// there are multiple different formats of error messages for this error code
// let's make sure to check both that we know about
match = err.detail.match(/Key \((.*?)\)=\((.*?)\) already exists/);
match = match || err.detail.match(/Key \((.*?)\)=\((.*?)\) is duplicated/);
return new sequelizeErrors.UniqueConstraintError({
fields: match[1].split(', '),
value: match[2].split(', '),
index: null,
parent: err
});
// this regex should check at least two
match = err.detail.match(/Key \((.*?)\)=\((.*?)\)/);
if (match) {
return new sequelizeErrors.UniqueConstraintError({
fields: match[1].split(', '),
value: match[2].split(', '),
index: null,
parent: err
});
} else {
return new sequelizeErrors.UniqueConstraintError({
error: err,
message: 'Could not further parse error message.'
});
}
default:
return new sequelizeErrors.DatabaseError(err);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!