SFC still trying to render template after throwing error in async setup #9694
-
Hi, I'm trying to use <script setup lang="ts">
checkForPermissions("read", "write"); // throws UnauthorizedError
const data = await useFetch("api/data");
</script>
<!-- I don't expect this to attempt to render -->
<template>
<SomePage :data="data" />
</template> In a parent component I wish to handle these errors: onErrorCaptured((e) => {
if (e instanceof UnauthorizedError || e instanceof NotFoundError) {
error.value = e;
return false;
}
return true;
}); But instead my application crashes and doesn't render my fallback for the This only happens with async setup as far as I can tell. I should mention the errors thrown are:
and:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
More detailed example: https://github.com/PindaPixel/vue-dir-routing/blob/main/src/modules/Reports/Pages/Capacity/CapacityPage.vue at URL |
Beta Was this translation helpful? Give feedback.
-
Okay so the problem was that my error boundary component was inside the suspense component. Instead the suspense should be inside the error boundary component. |
Beta Was this translation helpful? Give feedback.
Okay so the problem was that my error boundary component was inside the suspense component. Instead the suspense should be inside the error boundary component.