Rocky_Mountain_Vending/.pnpm-store/v10/files/84/7334186dd9c3dd21ef4fbbc5ed0a36d97331a86e6c968a940b9c16c7e417a18e501337718325608c3ddaecf7830fb5e9762238b2ce1c293f9eb1929fbc470f
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
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>
2026-02-12 16:22:15 -07:00

61 lines
No EOL
2.4 KiB
Text

const invalidServerComponentReactHooks = [
'useDeferredValue',
'useEffect',
'useImperativeHandle',
'useInsertionEffect',
'useLayoutEffect',
'useReducer',
'useRef',
'useState',
'useSyncExternalStore',
'useTransition',
'experimental_useOptimistic',
'useOptimistic'
];
function setMessage(error, message) {
error.message = message;
if (error.stack) {
const lines = error.stack.split('\n');
lines[0] = message;
error.stack = lines.join('\n');
}
}
/**
* Input:
* Error: Something went wrong
at funcName (/path/to/file.js:10:5)
at anotherFunc (/path/to/file.js:15:10)
* Output:
at funcName (/path/to/file.js:10:5)
at anotherFunc (/path/to/file.js:15:10)
*/ export function getStackWithoutErrorMessage(error) {
const stack = error.stack;
if (!stack) return '';
return stack.replace(/^[^\n]*\n/, '');
}
export function formatServerError(error) {
if (typeof (error == null ? void 0 : error.message) !== 'string') return;
if (error.message.includes('Class extends value undefined is not a constructor or null')) {
const addedMessage = 'This might be caused by a React Class Component being rendered in a Server Component, React Class Components only works in Client Components. Read more: https://nextjs.org/docs/messages/class-component-in-server-component';
// If this error instance already has the message, don't add it again
if (error.message.includes(addedMessage)) return;
setMessage(error, `${error.message}
${addedMessage}`);
return;
}
if (error.message.includes('createContext is not a function')) {
setMessage(error, 'createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component');
return;
}
for (const clientHook of invalidServerComponentReactHooks){
const regex = new RegExp(`\\b${clientHook}\\b.*is not a function`);
if (regex.test(error.message)) {
setMessage(error, `${clientHook} only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/react-client-hook-in-server-component`);
return;
}
}
}
//# sourceMappingURL=format-server-error.js.map