| 563 | } |
| 564 | |
| 565 | private formatResult(result: unknown): string { |
| 566 | if (result === undefined || result === null) { |
| 567 | return ""; |
| 568 | } |
| 569 | |
| 570 | if (typeof result === "string") { |
| 571 | return result; |
| 572 | } |
| 573 | |
| 574 | if ( |
| 575 | typeof result === "number" || |
| 576 | typeof result === "boolean" || |
| 577 | typeof result === "bigint" |
| 578 | ) { |
| 579 | return result.toString(); |
| 580 | } |
| 581 | |
| 582 | if (typeof result === "object") { |
| 583 | try { |
| 584 | return JSON.stringify(result); |
| 585 | } catch { |
| 586 | return Object.prototype.toString.call(result); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | return String(result); |
| 591 | } |
| 592 | |
| 593 | private ensureNotAborted() { |
| 594 | const abort = this.choiceExecutor.consumeAbortSignal?.(); |