Skip to content

Commit bbf9a42

Browse files
authored
ENG-1149 add try / catch to migration when querying for relation patterns (#624)
* ENG-1149 try-catch when getRelationData fails
1 parent 5505b71 commit bbf9a42

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

apps/roam/src/utils/getRelationData.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fireQuery from "./fireQuery";
22
import getDiscourseNodes from "./getDiscourseNodes";
33
import getDiscourseRelations from "./getDiscourseRelations";
44
import type { DiscourseRelation } from "./getDiscourseRelations";
5+
import internalError from "./internalError";
56

67
// lifted from getExportTypes
78

@@ -39,14 +40,23 @@ export const getRelationDataUtil = async (
3940
label: "target",
4041
},
4142
],
42-
}).then((results) =>
43-
results.map((result) => ({
44-
source: result.uid,
45-
target: result["target-uid"],
46-
relUid: s.id,
47-
label: s.label,
48-
})),
49-
);
43+
})
44+
.then((results) =>
45+
results.map((result) => ({
46+
source: result.uid,
47+
target: result["target-uid"],
48+
relUid: s.id,
49+
label: s.label,
50+
})),
51+
)
52+
.catch((error) => {
53+
internalError({
54+
error,
55+
type: "Get relation data",
56+
userMessage: `Could not find relations of type ${s.label}`,
57+
});
58+
return [];
59+
});
5060
}),
5161
).then((r) => r.flat());
5262

0 commit comments

Comments
 (0)