-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for SSR, revamp error handling
- Loading branch information
Showing
10 changed files
with
143 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
<script setup lang="ts"> | ||
const { loading: { onMountedWithLoading, clearLoading }, error: { errorModalVisible, error } } = useModal() | ||
const handleError = (err: Error) => { | ||
error.value = err | ||
errorModalVisible.value = true | ||
clearLoading() | ||
} | ||
onErrorCaptured((err: unknown, _instance: ComponentPublicInstance | null, _info: string) => { | ||
let error: Error | undefined | ||
if (err instanceof Error) { | ||
error = err | ||
} else if (typeof (err) === 'string') { | ||
error = new Error(err) | ||
} else { | ||
error = new Error('unknown error', { cause: err }) | ||
} | ||
handleError(error) | ||
return false // Don't propagate | ||
}) | ||
onMountedWithLoading(() => { /* nothing to do */ }, 'defaultLayout.onMountedWithLoading') | ||
</script> | ||
|
||
<template> | ||
<NuxtLayout /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script setup lang="ts"> | ||
// We get the equivalent of props.error from useError() in the ModalError component. | ||
// const props = defineProps({ | ||
// error: Object | ||
// }) | ||
const { error: { errorModalVisible } } = useModal() | ||
errorModalVisible.value = true | ||
</script> | ||
|
||
<template> | ||
<ModalError :is-full-page="true" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,5 +55,5 @@ const adminItems: AdminItem[] = [ | |
</PVCard> | ||
</div> | ||
</div> | ||
</standardcontent> | ||
</StandardContent> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters