import"./rolldown-runtime-DIIn1E2Q.js";import{qt as e}from"./api-BebQfoGK.js";import{o as t}from"./i18n-dAUEhQVe.js";function useErrorHandling(){let n=e(),toastErrorHandler=e=>{let r=e instanceof TypeError&&/failed to fetch|networkerror|load failed/i.test(e.message)?t(`g.disconnectedFromBackend`):e instanceof Error?e.message:t(`g.unknownError`);n.add({severity:`error`,summary:t(`g.error`),detail:r}),console.error(e)},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-DudkVSep.js.map