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

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() { ...@@ -253,16 +253,22 @@ module.exports = (function() {
}); });
case '23505': case '23505':
// there are multiple different formats of error messages for this error code // there are multiple different formats of error messages for this error code
// let's make sure to check both that we know about // this regex should check at least two
match = err.detail.match(/Key \((.*?)\)=\((.*?)\) already exists/); match = err.detail.match(/Key \((.*?)\)=\((.*?)\)/);
match = match || err.detail.match(/Key \((.*?)\)=\((.*?)\) is duplicated/);
if (match) {
return new sequelizeErrors.UniqueConstraintError({ return new sequelizeErrors.UniqueConstraintError({
fields: match[1].split(', '), fields: match[1].split(', '),
value: match[2].split(', '), value: match[2].split(', '),
index: null, index: null,
parent: err parent: err
}); });
} else {
return new sequelizeErrors.UniqueConstraintError({
error: err,
message: 'Could not further parse error message.'
});
}
default: default:
return new sequelizeErrors.DatabaseError(err); 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!