all-catch.ts 406 B

1234567
  1. // .catch on a real Promise (Promise.all returns Promise<string[]>). Runtime: if any
  2. // ask rejects, fallback runs and its result becomes the awaited value. The keystone
  3. // rule must let the fallback ask reach the return sink.
  4. const a = agent("a").ask<string>("x");
  5. const b = agent("b").ask<string>("y");
  6. const r = await Promise.all([a, b]).catch(() => agent("fallback").ask<string>("recover"));
  7. return r;