mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: catch-all exceptions
This commit is contained in:
1 parent
cfce5ececa
commit
3656868b66
2 files changed
+17
-3
No files matched your search
@@ -42,6 +42,7 @@ export class Quest {
|
||||
completed: string[]
|
||||
): Promise<string | null> {
|
||||
const stages = this.getActiveStages(completed)
|
||||
let catchAllException: string | null = null
|
||||
for (const stage of stages) {
|
||||
const satisfies = await stage.satisfies(command, this.checker)
|
||||
if (satisfies) {
|
||||
@@ -50,7 +51,9 @@ export class Quest {
|
||||
}
|
||||
for (const exception of stages.flatMap((stage) => stage.exceptions)) {
|
||||
const condition = new Condition(exception.condition)
|
||||
if (await condition.satisfies(command, this.checker)) {
|
||||
if (exception.catchAll && !catchAllException) {
|
||||
catchAllException = exception.id
|
||||
} else if (await condition.satisfies(command, this.checker)) {
|
||||
return exception.id
|
||||
}
|
||||
}
|
||||
@@ -60,7 +63,7 @@ export class Quest {
|
||||
return exception.id
|
||||
}
|
||||
}
|
||||
return null
|
||||
return catchAllException
|
||||
}
|
||||
|
||||
getResponses(completed: string[]): IResponse[] {
|
||||
|
||||
Reference in new issue
Block a user