<commit_before>import NextError from "next/error"
import t from "prop-types"

import NotFound from "component/Error/NotFound"

/**
 * @typedef {Object} PageErrorObject
 *
 * @prop {string} name
 * @prop {string} message
 * @prop {number} [status]
 * @prop {number} [statusCode]
 * @prop {string} [code]
 * @prop {string} [stack]
 */

/**
 * @typedef {Object} PageErrorProps
 *
 * @prop {React.ReactNode} children
 * @prop {PageErrorObject} error
 */

/**
 * @type {React.FC<PageErrorProps>}
 */
const PageError = ({error, children}) => {
  if (!error) {
    // TODO: Add error boundary here
    return children
  }

  if (error.status === 404) {
    return <NotFound />
  }

  return <NextError {...error} />
}

PageError.propTypes = {
  children: t.node.isRequired,
  error: t.shape({
    name: t.string,
    message: t.string,
    code: t.string,
    status: t.number,
    stack: t.string,
    statusCode: t.number
  })
}

PageError.defaultProps = {
  error: null
}

export default PageError
<commit_msg>Add PageError component description<commit_after>import NextError from "next/error"
import t from "prop-types"

import NotFound from "component/Error/NotFound"

/**
 * @typedef {Object} PageErrorObject
 *
 * @prop {string} name
 * @prop {string} message
 * @prop {number} [status]
 * @prop {number} [statusCode]
 * @prop {string} [code]
 * @prop {string} [stack]
 */

/**
 * @typedef {Object} PageErrorProps
 *
 * @prop {React.ReactNode} children
 * @prop {PageErrorObject} error
 */

/**
 * Will render next/error component if an error prop is taken. Otherwise its own child component will be rendered.
 *
 * @type {React.FC<PageErrorProps>}
 */
const PageError = ({error, children}) => {
  if (!error) {
    // TODO: Add error boundary here
    return children
  }

  if (error.status === 404) {
    return <NotFound />
  }

  return <NextError {...error} />
}

PageError.propTypes = {
  children: t.node.isRequired,
  error: t.shape({
    name: t.string,
    message: t.string,
    code: t.string,
    status: t.number,
    stack: t.string,
    statusCode: t.number
  })
}

PageError.defaultProps = {
  error: null
}

export default PageError

{'fraction_non_alphanumeric': 0.15009293680297398, 'fraction_numerical': 0.0027881040892193307, 'mean_word_length': 3.2974051896207586, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686227', 'n_tokens_mistral': 733, 'n_tokens_neox': 720, 'n_words': 197}