diff --git a/packages/lexical-website-new/src/pages/docs/error/index.js b/packages/lexical-website-new/src/pages/docs/error/index.js new file mode 100644 index 000000000..9537700eb --- /dev/null +++ b/packages/lexical-website-new/src/pages/docs/error/index.js @@ -0,0 +1,71 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +import BrowserOnly from '@docusaurus/BrowserOnly'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +import Layout from '@theme/Layout'; +import React, {useMemo} from 'react'; + +import codes from '../../../../../../scripts/error-codes/codes.json'; +import styles from './styles.module.css'; + +export default function ErrorCodePage() { + const {siteConfig} = useDocusaurusContext(); + return ( + +
+

Error Code

+

+ In the minified production build of Lexical, we avoid sending down + full error messages in order to reduce the number of bytes sent over + the wire. +

+ +

+ We highly recommend using the development build locally when debugging + your app since it tracks additional debug info and provides helpful + warnings about potential problems in your apps, but if you encounter + an exception while using the production build, this page will + reassemble the original text of the error. +

+ + {() => } +
+
+ ); +} + +function ErrorFinder() { + const error = useMemo(() => { + const code = new URLSearchParams(window.location.search).get('code'); + if (code === null) { + return null; + } + const description = codes[code]; + if (description === undefined) { + return null; + } + return {code, description}; + }, []); + + if (error !== null) { + return ( + <> +

Error code #{error.code}

+
{error.description}
+ + ); + } else { + return ( +

+ When you encounter an error, you'll receive a link to this page for that + specific error and we'll show you the full error text. +

+ ); + } +} diff --git a/packages/lexical-website-new/src/pages/docs/error/styles.module.css b/packages/lexical-website-new/src/pages/docs/error/styles.module.css new file mode 100644 index 000000000..512d0ff10 --- /dev/null +++ b/packages/lexical-website-new/src/pages/docs/error/styles.module.css @@ -0,0 +1,7 @@ +/* todo dark mode */ + +.errorContainer { + background-color: #ffbaba; + color: #a70000; + padding: 16px; +} diff --git a/scripts/error-codes/formatProdErrorMessage.js b/scripts/error-codes/formatProdErrorMessage.js index d712749eb..e0fd9d9a0 100644 --- a/scripts/error-codes/formatProdErrorMessage.js +++ b/scripts/error-codes/formatProdErrorMessage.js @@ -14,7 +14,7 @@ function formatProdErrorMessage(code) { throw Error( - `Minified Lexical error #${code}; see codes.json for the full message or ` + + `Minified Lexical error #${code}; visit https://lexical.dev/docs/error?code=${code} for the full message or ` + 'use the non-minified dev environment for full errors and additional ' + 'helpful warnings.', );