throw-catch.ts 323 B

12345678
  1. // throw/catch dataflow: a facade site inside a thrown expression must be evaluated,
  2. // and the catch binding must read the thrown value (ask#2 result) that is returned.
  3. const a = await agent("alpha").ask<string>("one");
  4. try {
  5. throw await agent("beta").ask<string>(`Rethink: ${a}`);
  6. } catch (e) {
  7. return e as string;
  8. }