* Wraps a mutation so that, when thread mutations are unavailable on the * connected runtime, the call rejects with a descriptive error instead of * issuing a request doomed to fail.
(
mutationsError: () => Error | null,
mutation: (threadId: string, name: string) => Promise<void>,
)
| 516 | * issuing a request doomed to fail. |
| 517 | */ |
| 518 | #guardMutation( |
| 519 | mutationsError: () => Error | null, |
| 520 | mutation: (threadId: string, name: string) => Promise<void>, |
| 521 | ): (threadId: string, name?: string) => Promise<void> { |
| 522 | return (threadId: string, name = "") => { |
| 523 | const error = mutationsError(); |
| 524 | if (error) { |
| 525 | return Promise.reject(error); |
| 526 | } |
| 527 | return mutation(threadId, name); |
| 528 | }; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | /** |