import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import{Tt as t}from"./api-DQLKc1Xa.js";import{o as n}from"./i18n-DjV_9lZM.js";function useErrorHandling(){let e=t(),toastErrorHandler=t=>{e.add({severity:`error`,summary:n(`g.error`),detail:t instanceof Error?t.message:n(`g.unknownError`)}),console.error(t)},wrapWithErrorHandling=(e,t,n)=>(...r)=>{try{return e(...r)}catch(e){(t??toastErrorHandler)(e)}finally{n?.()}},wrapWithErrorHandlingAsync=(e,t,n,r=[])=>async(...i)=>{try{return await e(...i)}catch(n){for(let t of r)if(t.shouldHandle(n))try{await t.recover(n,e,i);return}catch(e){console.error(`Recovery strategy failed:`,e)}(t??toastErrorHandler)(n)}finally{n?.()}};return{wrapWithErrorHandling,wrapWithErrorHandlingAsync,toastErrorHandler}}export{useErrorHandling as t};
//# sourceMappingURL=useErrorHandling-BFB8eSj5.js.map