Error handling
This commit is contained in:
parent
b808d76734
commit
60460da4f9
|
@ -20,10 +20,17 @@ export async function processInputBBReferences(
|
|||
}
|
||||
|
||||
for (const id of result) {
|
||||
try {
|
||||
const user = await cache.user.getUser(id)
|
||||
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
|
||||
default:
|
||||
|
|
|
@ -43,6 +43,11 @@ describe("bbReferenceProcessor", () => {
|
|||
it("throws an error given an invalid id", async () => {
|
||||
const userId = generator.guid()
|
||||
|
||||
mockedCacheGetUser.mockRejectedValue({
|
||||
status: 404,
|
||||
error: "not_found",
|
||||
})
|
||||
|
||||
await expect(
|
||||
processInputBBReferences(userId, FieldSubtype.USER)
|
||||
).rejects.toThrowError(new InvalidBBRefError(userId, FieldSubtype.USER))
|
||||
|
|
Loading…
Reference in New Issue