Download next.js/packages/next/src/next-devtools/shared/console-error.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 973 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/next-devtools/shared/console-error.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/next-devtools/shared/console-error.ts
-
curl -L -o console-error.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/next-devtools/shared/console-error.ts
973 Bytes
| // To distinguish from React error.digest, we use a different symbol here to determine if the error is from console.error or unhandled promise rejection. | |
| const digestSym = Symbol.for('next.console.error.digest') | |
| // Represent non Error shape unhandled promise rejections or console.error errors. | |
| // Those errors will be captured and displayed in Error Overlay. | |
| export type ConsoleError = Error & { | |
| [digestSym]: 'NEXT_CONSOLE_ERROR' | |
| environmentName: string | |
| } | |
| export function createConsoleError( | |
| message: string | Error, | |
| environmentName?: string | null | |
| ): ConsoleError { | |
| const error = ( | |
| typeof message === 'string' ? new Error(message) : message | |
| ) as ConsoleError | |
| error[digestSym] = 'NEXT_CONSOLE_ERROR' | |
| if (environmentName && !error.environmentName) { | |
| error.environmentName = environmentName | |
| } | |
| return error | |
| } | |
| export const isConsoleError = (error: any): error is ConsoleError => { | |
| return error && error[digestSym] === 'NEXT_CONSOLE_ERROR' | |
| } | |