UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 944 B
import{r as collectNestedErrorCandidates}from"./error-coercion-B-1Loz4b.mjs"; //!src/infra/error-graph-internal.ts async function settleWithCleanup(e,t,n){const[r]=await Promise.allSettled([e]);try{await t()}catch(e){if(r.status===`rejected`)throw new AggregateError([r.reason,e],n,{cause:e});throw e}if(r.status===`rejected`)throw r.reason;return r.value}function throwSettledAggregate(e,t){const n=e.flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(n.length)throw new AggregateError(n,t)}function materializeErrorStack(e){try{for(const t of collectNestedErrorCandidates(e))try{if(!(t instanceof Error))continue;try{t.stack=String(t.stack)}catch{t.stack=`Stack trace unavailable: custom formatter failed`}}catch{}}catch{}}function collectSynchronousErrors(e,t){const n=[];for(const r of e)try{t(r)}catch(e){n.push(e)}return n}export{throwSettledAggregate as i,materializeErrorStack as n,settleWithCleanup as r,collectSynchronousErrors as t};