Skip to content

Commit

Permalink
fix: don't crash when no error tag present (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanmckenzie authored Nov 14, 2020
1 parent 652d45f commit 2205953
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ConstraintErrorTagsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ async function ConstraintErrorTagsPlugin(_, { pgConfig }) {
constraintsWithErrorTags = rows
.map(({ description, ...rest }) => {
const error = parseTags(description).tags.error;
if (typeof error !== "string") {
throw new Error(
`ConstraintErrorTagsPlugin: expected error smart tag on "${rest.constraint}" to be a string, but got: ${error}.`
);
if (error) {
if (typeof error !== "string") {
throw new Error(
`ConstraintErrorTagsPlugin: expected error smart tag on "${rest.constraint}" to be a string, but got: ${error}.`
);
}
return {
...rest,
error,
};
}
return {
...rest,
error,
};
return rest;
})
.filter(({ error }) => Boolean(error));
});
Expand Down

0 comments on commit 2205953

Please sign in to comment.