Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
1 line
No EOL
6.8 KiB
Text
1 line
No EOL
6.8 KiB
Text
{"version":3,"sources":["../../../../../src/next-devtools/userspace/app/errors/use-error-handler.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { isNextRouterError } from '../../../../client/components/is-next-router-error'\nimport {\n formatConsoleArgs,\n parseConsoleArgs,\n} from '../../../../client/lib/console'\nimport isError from '../../../../lib/is-error'\nimport { createConsoleError } from '../../../shared/console-error'\nimport { coerceError, setOwnerStackIfAvailable } from './stitched-error'\nimport { forwardUnhandledError, logUnhandledRejection } from '../forward-logs'\n\nconst queueMicroTask =\n globalThis.queueMicrotask || ((cb: () => void) => Promise.resolve().then(cb))\n\ntype ErrorHandler = (error: Error) => void\n\nconst errorQueue: Array<Error> = []\nconst errorHandlers: Array<ErrorHandler> = []\nconst rejectionQueue: Array<Error> = []\nconst rejectionHandlers: Array<ErrorHandler> = []\n\nexport function handleConsoleError(\n originError: unknown,\n consoleErrorArgs: any[]\n) {\n let error: Error\n const { environmentName } = parseConsoleArgs(consoleErrorArgs)\n if (isError(originError)) {\n error = createConsoleError(originError, environmentName)\n } else {\n error = createConsoleError(\n formatConsoleArgs(consoleErrorArgs),\n environmentName\n )\n }\n setOwnerStackIfAvailable(error)\n\n errorQueue.push(error)\n for (const handler of errorHandlers) {\n // Delayed the error being passed to React Dev Overlay,\n // avoid the state being synchronously updated in the component.\n queueMicroTask(() => {\n handler(error)\n })\n }\n}\n\nexport function handleClientError(error: Error) {\n errorQueue.push(error)\n for (const handler of errorHandlers) {\n // Delayed the error being passed to React Dev Overlay,\n // avoid the state being synchronously updated in the component.\n queueMicroTask(() => {\n handler(error)\n })\n }\n}\n\nexport function useErrorHandler(\n handleOnUnhandledError: ErrorHandler,\n handleOnUnhandledRejection: ErrorHandler\n) {\n useEffect(() => {\n // Handle queued errors.\n errorQueue.forEach(handleOnUnhandledError)\n rejectionQueue.forEach(handleOnUnhandledRejection)\n\n // Listen to new errors.\n errorHandlers.push(handleOnUnhandledError)\n rejectionHandlers.push(handleOnUnhandledRejection)\n\n return () => {\n // Remove listeners.\n errorHandlers.splice(errorHandlers.indexOf(handleOnUnhandledError), 1)\n rejectionHandlers.splice(\n rejectionHandlers.indexOf(handleOnUnhandledRejection),\n 1\n )\n\n // Reset error queues.\n errorQueue.splice(0, errorQueue.length)\n rejectionQueue.splice(0, rejectionQueue.length)\n }\n }, [handleOnUnhandledError, handleOnUnhandledRejection])\n}\n\nfunction onUnhandledError(event: WindowEventMap['error']): void | boolean {\n const thrownValue: unknown = event.error\n if (isNextRouterError(thrownValue)) {\n event.preventDefault()\n return false\n }\n // When there's an error property present, we log the error to error overlay.\n // Otherwise we don't do anything as it's not logging in the console either.\n if (thrownValue) {\n const error = coerceError(thrownValue)\n setOwnerStackIfAvailable(error)\n handleClientError(error)\n forwardUnhandledError(error)\n }\n}\n\nfunction onUnhandledRejection(ev: WindowEventMap['unhandledrejection']): void {\n const reason: unknown = ev?.reason\n if (isNextRouterError(reason)) {\n ev.preventDefault()\n return\n }\n\n const error = coerceError(reason)\n setOwnerStackIfAvailable(error)\n\n rejectionQueue.push(error)\n for (const handler of rejectionHandlers) {\n handler(error)\n }\n\n logUnhandledRejection(reason)\n}\n\nexport function handleGlobalErrors() {\n if (typeof window !== 'undefined') {\n try {\n // Increase the number of stack frames on the client\n Error.stackTraceLimit = 50\n } catch {}\n\n window.addEventListener('error', onUnhandledError)\n window.addEventListener('unhandledrejection', onUnhandledRejection)\n }\n}\n"],"names":["useEffect","isNextRouterError","formatConsoleArgs","parseConsoleArgs","isError","createConsoleError","coerceError","setOwnerStackIfAvailable","forwardUnhandledError","logUnhandledRejection","queueMicroTask","globalThis","queueMicrotask","cb","Promise","resolve","then","errorQueue","errorHandlers","rejectionQueue","rejectionHandlers","handleConsoleError","originError","consoleErrorArgs","error","environmentName","push","handler","handleClientError","useErrorHandler","handleOnUnhandledError","handleOnUnhandledRejection","forEach","splice","indexOf","length","onUnhandledError","event","thrownValue","preventDefault","onUnhandledRejection","ev","reason","handleGlobalErrors","window","Error","stackTraceLimit","addEventListener"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAO;AACjC,SAASC,iBAAiB,QAAQ,qDAAoD;AACtF,SACEC,iBAAiB,EACjBC,gBAAgB,QACX,iCAAgC;AACvC,OAAOC,aAAa,2BAA0B;AAC9C,SAASC,kBAAkB,QAAQ,gCAA+B;AAClE,SAASC,WAAW,EAAEC,wBAAwB,QAAQ,mBAAkB;AACxE,SAASC,qBAAqB,EAAEC,qBAAqB,QAAQ,kBAAiB;AAE9E,MAAMC,iBACJC,WAAWC,cAAc,IAAK,CAAA,CAACC,KAAmBC,QAAQC,OAAO,GAAGC,IAAI,CAACH,GAAE;AAI7E,MAAMI,aAA2B,EAAE;AACnC,MAAMC,gBAAqC,EAAE;AAC7C,MAAMC,iBAA+B,EAAE;AACvC,MAAMC,oBAAyC,EAAE;AAEjD,OAAO,SAASC,mBACdC,WAAoB,EACpBC,gBAAuB;IAEvB,IAAIC;IACJ,MAAM,EAAEC,eAAe,EAAE,GAAGtB,iBAAiBoB;IAC7C,IAAInB,QAAQkB,cAAc;QACxBE,QAAQnB,mBAAmBiB,aAAaG;IAC1C,OAAO;QACLD,QAAQnB,mBACNH,kBAAkBqB,mBAClBE;IAEJ;IACAlB,yBAAyBiB;IAEzBP,WAAWS,IAAI,CAACF;IAChB,KAAK,MAAMG,WAAWT,cAAe;QACnC,uDAAuD;QACvD,gEAAgE;QAChER,eAAe;YACbiB,QAAQH;QACV;IACF;AACF;AAEA,OAAO,SAASI,kBAAkBJ,KAAY;IAC5CP,WAAWS,IAAI,CAACF;IAChB,KAAK,MAAMG,WAAWT,cAAe;QACnC,uDAAuD;QACvD,gEAAgE;QAChER,eAAe;YACbiB,QAAQH;QACV;IACF;AACF;AAEA,OAAO,SA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