mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Merge pull request #1302 from hgiesel/hookhandle
Catch reviewer hook errors in two ways
This commit is contained in:
commit
b61e90e995
2 changed files with 19 additions and 5 deletions
|
@ -27,14 +27,21 @@ export function getTypedAnswer(): string | null {
|
||||||
return typeans?.value ?? null;
|
return typeans?.value ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _runHook(arr: Array<Callback>): Promise<void[]> {
|
function _runHook(
|
||||||
|
hooks: Array<Callback>
|
||||||
|
): Promise<PromiseSettledResult<void | Promise<void>>[]> {
|
||||||
const promises: (Promise<void> | void)[] = [];
|
const promises: (Promise<void> | void)[] = [];
|
||||||
|
|
||||||
for (let i = 0; i < arr.length; i++) {
|
for (const hook of hooks) {
|
||||||
promises.push(arr[i]());
|
try {
|
||||||
|
const result = hook();
|
||||||
|
promises.push(result);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Hook failed: ", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(promises);
|
return Promise.allSettled(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
let _updatingQueue: Promise<void> = Promise.resolve();
|
let _updatingQueue: Promise<void> = Promise.resolve();
|
||||||
|
|
|
@ -3,7 +3,14 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "es6",
|
"module": "es6",
|
||||||
"lib": ["es2017", "es2019.array", "es2018.promise", "dom", "dom.iterable"],
|
"lib": [
|
||||||
|
"es2017",
|
||||||
|
"es2019.array",
|
||||||
|
"es2018.promise",
|
||||||
|
"es2020.promise",
|
||||||
|
"dom",
|
||||||
|
"dom.iterable"
|
||||||
|
],
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"lib/*": ["../bazel-bin/ts/lib/*"],
|
"lib/*": ["../bazel-bin/ts/lib/*"],
|
||||||
|
|
Loading…
Reference in a new issue