import React from "react";

interface ErrorPageProps {
  statusCode: number
};

export default function Error(props: ErrorPageProps) {
  return (
    <p>
      {props.statusCode
        ? `An error ${props.statusCode} occurred on server`
        : "An error occurred on client"}
    </p>
  )
}

export const getInitialProps = ({ res, err }) => {
  const statusCode = res ? res.statusCode : err ? err.statusCode : 404
  return { props: { statusCode } };
};
