mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
f43e1a95f1
* Set default `Error` status code to 404 This is an appropriate default behavior because: 1. When the server encounters an error, the `err` property is set. 2. When the client-side application crashes, the `err` property is set. This means the "only" way to render the `/_error` page without an error is when a page is not found (special condition). Fixes #6243 Closes #5437 * Add new integration test for client side 404 * single quotes * Remove unused variable * Standard needs to go away * Whoops * Check for null status code in res and err * Only check response for valid statusCode
24 lines
540 B
JavaScript
24 lines
540 B
JavaScript
import Link from 'next/link'
|
|
import NextError from 'next/error'
|
|
import React from 'react'
|
|
|
|
export default class Error extends React.Component {
|
|
static getInitialProps (ctx) {
|
|
const { statusCode } = NextError.getInitialProps(ctx)
|
|
return { statusCode: statusCode || null }
|
|
}
|
|
|
|
render () {
|
|
return (
|
|
<div>
|
|
<div id='errorStatusCode'>{this.props.statusCode || 'unknown'}</div>
|
|
<p>
|
|
<Link href='/'>
|
|
<a id='errorGoHome'>go home</a>
|
|
</Link>
|
|
</p>
|
|
</div>
|
|
)
|
|
}
|
|
}
|