openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.09 kB
JavaScript
import{P as e}from"./transcript-plugin-instance-invocation-7pP9ZY8b.mjs";async function settleWithCleanup(e,t,n){let[r]=await Promise.allSettled([e]);try{await t()}catch(e){throw r.status===`rejected`?AggregateError([r.reason,e],n,{cause:e}):e}if(r.status===`rejected`)throw r.reason;return r.value}function throwIfSettledRejected(e,t){throwCollectedErrors(e.flatMap(e=>e.status===`rejected`?[e.reason]:[]),t)}function throwSettledAggregate(e,t){let n=e.flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(n.length)throw AggregateError(n,t)}function throwCollectedErrors(e,t){if(e.length===1)throw e[0];if(e.length>1)throw AggregateError(e,t)}function materializeErrorStack(t){try{for(let n of e(t))try{if(!(n instanceof Error))continue;try{n.stack=String(n.stack)}catch{n.stack=`Stack trace unavailable: custom formatter failed`}}catch{}}catch{}}function collectSynchronousErrors(e,t){let n=[];for(let r of e)try{t(r)}catch(e){n.push(e)}return n}export{throwSettledAggregate as a,throwIfSettledRejected as i,materializeErrorStack as n,settleWithCleanup as r,collectSynchronousErrors as t};