From 285cc0ea44a221c26ec30763dab9e6791c96d140 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Wed, 20 Dec 2023 15:41:11 +0530 Subject: [PATCH] Features/release checklist (#42) * :art: Added logs, and improved debugging * :art: Error handling improved --- lib/app-setup/root.tsx | 10 ++++++++-- lib/client/helpers/log.ts | 10 ++++------ lib/utils/common.tsx | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/app-setup/root.tsx b/lib/app-setup/root.tsx index dc8ca64b2..ac6bd362b 100644 --- a/lib/app-setup/root.tsx +++ b/lib/app-setup/root.tsx @@ -29,6 +29,7 @@ import { TopBar } from '~/components/organisms/top-bar'; import styleZenerSelect from '@oshq/react-select/index.css'; import stylesUrl from '~/design-system/index.css'; import rcss from 'react-highlightjs-logs/dist/index.css'; +import { isDev } from '../client/helpers/log'; export const links = () => [ { rel: 'stylesheet', href: stylesUrl }, @@ -96,9 +97,14 @@ export function ErrorBoundary() { if (error instanceof Error) { return ( - + - {typeof error.stack === 'string' + {/* eslint-disable-next-line no-nested-ternary */} + {isDev + ? typeof error.stack === 'string' + ? error.stack + : JSON.stringify(error.stack, null, 2) + : typeof error.stack === 'string' ? error.stack : JSON.stringify(error.stack, null, 2)} diff --git a/lib/client/helpers/log.ts b/lib/client/helpers/log.ts index c3bbdb7f9..e3cc635c7 100644 --- a/lib/client/helpers/log.ts +++ b/lib/client/helpers/log.ts @@ -56,7 +56,7 @@ const PostToHook = (message: string) => { return {}; }; -const isDev = getNodeEnv() === 'development'; +export const isDev = getNodeEnv() === 'development'; const logger = { time: isDev ? console.time : () => {}, @@ -98,11 +98,9 @@ const logger = { console.trace(args); } - // if (isDev && typeof window === 'undefined') { - // serverError(args); - // } - - serverError(args); + if (isDev && typeof window === 'undefined') { + serverError(args); + } }, }; diff --git a/lib/utils/common.tsx b/lib/utils/common.tsx index 96f5965d3..fb71ad287 100644 --- a/lib/utils/common.tsx +++ b/lib/utils/common.tsx @@ -3,8 +3,8 @@ import logger from '../client/helpers/log'; export const handleError = (e: unknown): void => { const err = e as Error; - logger.error(e); toast.error(err.message); + logger.error(e); }; export const parseError = (e: unknown): Error => {