Error handling
This commit is contained in:
parent
d62e9a475f
commit
679f56f32f
|
@ -20,9 +20,16 @@ export async function processInputBBReferences(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const id of result) {
|
for (const id of result) {
|
||||||
const user = await cache.user.getUser(id)
|
try {
|
||||||
if (!user) {
|
const user = await cache.user.getUser(id)
|
||||||
throw new InvalidBBRefError(id, FieldSubtype.USER)
|
if (!user) {
|
||||||
|
throw new InvalidBBRefError(id, FieldSubtype.USER)
|
||||||
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
if (err != null && err.status === 404 && err.error === "not_found") {
|
||||||
|
throw new InvalidBBRefError(id, FieldSubtype.USER)
|
||||||
|
}
|
||||||
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
|
@ -43,6 +43,11 @@ describe("bbReferenceProcessor", () => {
|
||||||
it("throws an error given an invalid id", async () => {
|
it("throws an error given an invalid id", async () => {
|
||||||
const userId = generator.guid()
|
const userId = generator.guid()
|
||||||
|
|
||||||
|
mockedCacheGetUser.mockRejectedValue({
|
||||||
|
status: 404,
|
||||||
|
error: "not_found",
|
||||||
|
})
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
processInputBBReferences(userId, FieldSubtype.USER)
|
processInputBBReferences(userId, FieldSubtype.USER)
|
||||||
).rejects.toThrowError(new InvalidBBRefError(userId, FieldSubtype.USER))
|
).rejects.toThrowError(new InvalidBBRefError(userId, FieldSubtype.USER))
|
||||||
|
|
Loading…
Reference in New Issue