mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Remove pageNotFound key from the error.
This commit is contained in:
parent
866319c76d
commit
6f9b51fce6
|
@ -5,13 +5,12 @@ import Head from './head'
|
||||||
export default class Error extends React.Component {
|
export default class Error extends React.Component {
|
||||||
static getInitialProps ({ res, err }) {
|
static getInitialProps ({ res, err }) {
|
||||||
const statusCode = res ? res.statusCode : (err ? err.statusCode : null)
|
const statusCode = res ? res.statusCode : (err ? err.statusCode : null)
|
||||||
const pageNotFound = statusCode === 404 || (err ? err.pageNotFound : false)
|
return { statusCode }
|
||||||
return { statusCode, pageNotFound }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { statusCode, pageNotFound } = this.props
|
const { statusCode } = this.props
|
||||||
const title = pageNotFound
|
const title = statusCode === 404
|
||||||
? 'This page could not be found'
|
? 'This page could not be found'
|
||||||
: HTTPStatus[statusCode] || 'An unexpected error has occurred'
|
: HTTPStatus[statusCode] || 'An unexpected error has occurred'
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ export default class Router {
|
||||||
return { error: err }
|
return { error: err }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err.pageNotFound) {
|
if (err.statusCode === 404) {
|
||||||
// Indicate main error display logic to
|
// Indicate main error display logic to
|
||||||
// ignore rendering this error as a runtime error.
|
// ignore rendering this error as a runtime error.
|
||||||
err.ignore = true
|
err.ignore = true
|
||||||
|
|
|
@ -124,7 +124,6 @@ export async function renderScriptError (req, res, page, error, customFields, op
|
||||||
res.end(`
|
res.end(`
|
||||||
function loadPage () {
|
function loadPage () {
|
||||||
var error = new Error('Page not exists: ${page}')
|
var error = new Error('Page not exists: ${page}')
|
||||||
error.pageNotFound = true
|
|
||||||
error.statusCode = 404
|
error.statusCode = 404
|
||||||
__NEXT_PAGE_LOADER__.registerPage('${page}', function(cb) {
|
__NEXT_PAGE_LOADER__.registerPage('${page}', function(cb) {
|
||||||
cb(error)
|
cb(error)
|
||||||
|
|
Loading…
Reference in a new issue