mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(vue-app): allow passing custom props to error function (#4462)
Resolves #4460.
This commit is contained in:
parent
e99a6691fb
commit
a6fed0acbd
@ -285,6 +285,7 @@ export function normalizeError(err) {
|
|||||||
message = err.message || err
|
message = err.message || err
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
...err,
|
||||||
message: message,
|
message: message,
|
||||||
statusCode: (err.statusCode || err.status || (err.response && err.response.status) || 500)
|
statusCode: (err.statusCode || err.status || (err.response && err.response.status) || 500)
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ describe('basic browser', () => {
|
|||||||
await page.nuxt.navigate('/error2')
|
await page.nuxt.navigate('/error2')
|
||||||
|
|
||||||
expect(await page.$text('.title')).toBe('Custom error')
|
expect(await page.$text('.title')).toBe('Custom error')
|
||||||
expect(await page.nuxt.errorData()).toEqual({ message: 'Custom error', statusCode: 500 })
|
expect(await page.nuxt.errorData()).toEqual({ message: 'Custom error', statusCode: 500, customProp: 'ezpz' })
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/redirect-middleware', async () => {
|
test('/redirect-middleware', async () => {
|
||||||
|
2
test/fixtures/basic/pages/error2.vue
vendored
2
test/fixtures/basic/pages/error2.vue
vendored
@ -5,7 +5,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
asyncData({ error }) {
|
asyncData({ error }) {
|
||||||
error({ message: 'Custom error' })
|
error({ message: 'Custom error', customProp: 'ezpz' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -235,6 +235,7 @@ describe('basic ssr', () => {
|
|||||||
expect(html).toContain('Custom error')
|
expect(html).toContain('Custom error')
|
||||||
expect(error.message).toContain('Custom error')
|
expect(error.message).toContain('Custom error')
|
||||||
expect(error.statusCode).toBe(500)
|
expect(error.statusCode).toBe(500)
|
||||||
|
expect(error.customProp).toBe('ezpz')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/error2 status code', async () => {
|
test('/error2 status code', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user