mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2026-03-01 18:31:35 +00:00
Handle user not found in assistant
This commit is contained in:
parent
b2b84c0663
commit
99213216f7
4 changed files with 23 additions and 3 deletions
|
|
@ -26,9 +26,14 @@ class Assistant {
|
|||
if (root.status === "ok") {
|
||||
this.lastRequestStatus = constants.symbols.assistant_statuses.OK
|
||||
resolve(root.data.user)
|
||||
} else {
|
||||
this.lastRequestStatus = constants.symbols.assistant_statuses.BLOCKED
|
||||
reject(constants.symbols.assistant_statuses.BLOCKED)
|
||||
} else { // "fail"
|
||||
if (root.identifier === "NOT_FOUND") {
|
||||
this.lastRequestStatus = constants.symbols.assistant_statuses.OK
|
||||
reject(constants.symbols.NOT_FOUND)
|
||||
} else { // blocked
|
||||
this.lastRequestStatus = constants.symbols.assistant_statuses.BLOCKED
|
||||
reject(constants.symbols.assistant_statuses.BLOCKED)
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
// console.error(error)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ class AssistantSwitcher {
|
|||
const user = await assistant.requestUser(username)
|
||||
return resolve(user)
|
||||
} catch (e) {
|
||||
if (e === constants.symbols.NOT_FOUND) {
|
||||
const rejection = Promise.reject(e)
|
||||
rejection.catch(() => {}) // otherwise we get a warning that the rejection was handled asynchronously
|
||||
collectors.userRequestCache.set(`user/${username}`, false, rejection)
|
||||
return reject(e)
|
||||
}
|
||||
// that assistant broke. try the next one.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue