(command: IChoiceCommand)
| 545 | } |
| 546 | |
| 547 | protected async executeChoice(command: IChoiceCommand) { |
| 548 | let targetChoice: IChoice; |
| 549 | try { |
| 550 | targetChoice = this.plugin.getChoiceById(command.choiceId); |
| 551 | } catch (error) { |
| 552 | // getChoiceById throws ONLY a "Choice <id> not found" error when the |
| 553 | // referenced choice was deleted; surface a friendly message naming the |
| 554 | // stored command and skip instead of aborting the whole macro. Rethrow |
| 555 | // anything else so a genuine fault isn't silently swallowed (which would |
| 556 | // let the macro continue in a corrupted state). |
| 557 | const message = error instanceof Error ? error.message : String(error); |
| 558 | if (!/not found/i.test(message)) throw error; |
| 559 | log.logError( |
| 560 | `choice '${command.name}' could not be found.` |
| 561 | ); |
| 562 | return; |
| 563 | } |
| 564 | |
| 565 | await this.choiceExecutor.execute(targetChoice); |
| 566 | const abort = this.choiceExecutor.consumeAbortSignal?.(); |
| 567 | if (abort) { |
| 568 | throw abort; |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | private async executeNestedChoice(command: INestedChoiceCommand) { |
| 573 | const choice: IChoice = command.choice; |
no test coverage detected