fix(vue-app): allow passing custom props to error function (#4462)

Resolves #4460.
This commit is contained in:
Dmitry Molotkov 2018-11-30 22:15:29 +03:00 committed by Pooya Parsa
parent e99a6691fb
commit a6fed0acbd
4 changed files with 4 additions and 2 deletions

View File

@ -285,6 +285,7 @@ export function normalizeError(err) {
message = err.message || err
}
return {
...err,
message: message,
statusCode: (err.statusCode || err.status || (err.response && err.response.status) || 500)
}

View File

@ -166,7 +166,7 @@ describe('basic browser', () => {
await page.nuxt.navigate('/error2')
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 () => {

View File

@ -5,7 +5,7 @@
<script>
export default {
asyncData({ error }) {
error({ message: 'Custom error' })
error({ message: 'Custom error', customProp: 'ezpz' })
}
}
</script>

View File

@ -235,6 +235,7 @@ describe('basic ssr', () => {
expect(html).toContain('Custom error')
expect(error.message).toContain('Custom error')
expect(error.statusCode).toBe(500)
expect(error.customProp).toBe('ezpz')
})
test('/error2 status code', async () => {