Skip to content

Commit 902cb00

Browse files
committed
feat: port upstream error composable improvements
1 parent 5e71ab2 commit 902cb00

File tree

1 file changed

+8
-3
lines changed
  • packages/bridge/src/runtime/composables

1 file changed

+8
-3
lines changed

packages/bridge/src/runtime/composables/error.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@ import { useNuxtApp } from '../nuxt'
44

55
export const NUXT_ERROR_SIGNATURE = '__nuxt_error'
66

7+
/* @__NO_SIDE_EFFECTS__ */
78
export const useError = () => toRef(useNuxtApp().payload, 'error')
89

9-
export interface NuxtError<DataT = unknown> extends H3Error<DataT> {}
10+
export interface NuxtError<DataT = unknown> extends H3Error<DataT> { }
1011

1112
export const showError = <DataT = unknown>(
1213
error: string | Error | Partial<NuxtError<DataT>>
1314
) => {
1415
const nuxtError = createError<DataT>(error)
1516

1617
try {
17-
const nuxtApp = useNuxtApp()
18-
nuxtApp.callHook('app:error', nuxtError)
1918
const error = useError()
19+
20+
if (process.client) {
21+
const nuxtApp = useNuxtApp()
22+
nuxtApp.callHook('app:error', nuxtError)
23+
}
24+
2025
error.value = error.value || nuxtError
2126
} catch {
2227
throw nuxtError

0 commit comments

Comments
 (0)