feat(core): wrap prompt middleware in try-finally block
Ensure the prompt status is cleared even if the middleware chain throws an error.
This commit is contained in:
parent
a0b2003c65
commit
09c3fc443b
|
|
@ -87,17 +87,20 @@ export abstract class BaseGameClient<
|
|||
}
|
||||
}
|
||||
|
||||
callback({
|
||||
hasPrompt: true,
|
||||
player: ctx.player || "global",
|
||||
def: ctx.def,
|
||||
tryAnswer,
|
||||
});
|
||||
await next();
|
||||
callback({
|
||||
hasPrompt: false,
|
||||
player: ctx.player || "global",
|
||||
});
|
||||
try {
|
||||
callback({
|
||||
hasPrompt: true,
|
||||
player: ctx.player || "global",
|
||||
def: ctx.def,
|
||||
tryAnswer,
|
||||
});
|
||||
return await next();
|
||||
} finally {
|
||||
callback({
|
||||
hasPrompt: false,
|
||||
player: ctx.player || "global",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
selectStatus(callback: (status: ClientStatus) => void) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue