2023-01-08 10:07:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2019-2021 Carl Kittelberger <icedream@icedream.pw>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { NextPage } from 'next';
|
|
|
|
|
import { ErrorProps } from 'next/error';
|
|
|
|
|
import Head from 'next/head';
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import { useIntl } from 'react-intl';
|
|
|
|
|
|
2023-01-09 01:33:50 +00:00
|
|
|
|
const Error: NextPage<ErrorProps> = function Error({
|
2023-01-08 10:07:44 +00:00
|
|
|
|
statusCode,
|
|
|
|
|
title,
|
2023-01-09 01:33:50 +00:00
|
|
|
|
}) {
|
2023-01-08 10:07:44 +00:00
|
|
|
|
const intl = useIntl();
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<Head>
|
|
|
|
|
<title>
|
2023-01-09 01:35:10 +00:00
|
|
|
|
{`${title} – ${intl.formatMessage({
|
2023-01-08 10:07:44 +00:00
|
|
|
|
id: 'App.title',
|
|
|
|
|
description: 'The full title of the website',
|
|
|
|
|
defaultMessage: 'Games Done Quick Instant Archive',
|
2023-01-09 01:35:10 +00:00
|
|
|
|
})}`}
|
2023-01-08 10:07:44 +00:00
|
|
|
|
</title>
|
|
|
|
|
</Head>
|
|
|
|
|
<p>
|
2023-01-09 01:35:10 +00:00
|
|
|
|
<h1>
|
|
|
|
|
{statusCode}
|
|
|
|
|
{' '}
|
|
|
|
|
{title}
|
|
|
|
|
</h1>
|
2023-01-08 10:07:44 +00:00
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2023-01-09 01:33:50 +00:00
|
|
|
|
);
|
|
|
|
|
};
|
2023-01-08 10:07:44 +00:00
|
|
|
|
|
|
|
|
|
Error.getInitialProps = (ctx) => {
|
|
|
|
|
const { res, err } = ctx;
|
2023-01-09 01:33:50 +00:00
|
|
|
|
// eslint-disable-next-line no-nested-ternary
|
|
|
|
|
const statusCode = res ? res.statusCode : (err ? err.statusCode : 404);
|
|
|
|
|
// eslint-disable-next-line no-nested-ternary
|
|
|
|
|
const title = res ? res.statusMessage : (err ? err.message : 'Page not found');
|
|
|
|
|
return { statusCode, title };
|
|
|
|
|
};
|
2023-01-08 10:07:44 +00:00
|
|
|
|
|
2023-01-09 01:33:50 +00:00
|
|
|
|
export default Error;
|