Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
227 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useRouter } from 'next/router' | ||
import { useEffect, useState } from 'react' | ||
import Debug from './debug' | ||
|
||
function transform(router) { | ||
return { | ||
pathname: router.pathname, | ||
asPath: router.asPath, | ||
query: Object.entries(router.query) | ||
.map(([key, value]) => [key, value].join('=')) | ||
.join('&'), | ||
isReady: router.isReady ? 'true' : 'false', | ||
} | ||
} | ||
|
||
export default function DebugError({ children }) { | ||
const router = useRouter() | ||
const [debug, setDebug] = useState({}) | ||
|
||
useEffect(() => { | ||
setDebug(transform(router)) | ||
}, [router]) | ||
|
||
return ( | ||
<> | ||
<dl> | ||
<Debug name="pathname" value={debug.pathname} /> | ||
<Debug name="asPath" value={debug.asPath} /> | ||
<Debug name="query" value={debug.query} /> | ||
<Debug name="isReady" value={debug.isReady} /> | ||
</dl> | ||
{children} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function Debug({ name, value }) { | ||
return ( | ||
<> | ||
<dt>{name}</dt> | ||
<dd id={name}>{value}</dd> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,5 @@ | ||
import { useRouter } from 'next/router' | ||
import { useEffect, useState } from 'react' | ||
|
||
function transform(router) { | ||
return { | ||
pathname: router.pathname, | ||
asPath: router.asPath, | ||
query: Object.entries(router.query) | ||
.map(([key, value]) => [key, value].join('=')) | ||
.join('&'), | ||
isReady: router.isReady ? 'true' : 'false', | ||
} | ||
} | ||
|
||
function Debug({ name, value }) { | ||
return ( | ||
<> | ||
<dt>{name}</dt> | ||
<dd id={name}>{value}</dd> | ||
</> | ||
) | ||
} | ||
import DebugError from '../components/debug-error' | ||
|
||
export default function Custom404() { | ||
const router = useRouter() | ||
const [debug, setDebug] = useState({}) | ||
|
||
useEffect(() => { | ||
setDebug(transform(router)) | ||
}, [router]) | ||
|
||
return ( | ||
<dl> | ||
<Debug name="pathname" value={debug.pathname} /> | ||
<Debug name="asPath" value={debug.asPath} /> | ||
<Debug name="query" value={debug.query} /> | ||
<Debug name="isReady" value={debug.isReady} /> | ||
</dl> | ||
) | ||
return <DebugError /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import DebugError from '../components/debug-error' | ||
import Debug from '../components/debug' | ||
|
||
function Error({ statusCode }) { | ||
return <DebugError /> | ||
} | ||
|
||
Error.getInitialProps = ({ res, err }) => { | ||
const statusCode = res ? res.statusCode : err ? err.statusCode : 404 | ||
return { statusCode } | ||
} | ||
|
||
export default Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page() { | ||
throw new Error('there was an error') | ||
} | ||
|
||
export const getServerSideProps = () => { | ||
return { props: {} } | ||
} |
Oops, something went wrong.