``refactor Enhance error logging in UserProvider by including full error details in development environment for debugging purposes``

This commit is contained in:
2025-05-16 11:02:45 +08:00
parent c5eb7100ea
commit 3d38af8100

View File

@@ -4,6 +4,7 @@ import * as React from 'react';
import type { User } from '@/types/user';
import { authClient } from '@/lib/auth/custom/client';
import isDevelopment from '@/lib/check-is-development';
import { logger } from '@/lib/default-logger';
import type { UserContextValue } from '../types';
@@ -27,7 +28,12 @@ export function UserProvider({ children }: UserProviderProps): React.JSX.Element
if (error) {
logger.error(error);
setState((prev) => ({ ...prev, user: null, error: 'Something went wrong', isLoading: false }));
setState((prev) => ({
...prev,
user: null,
error: `Something went wrong ${isDevelopment ? JSON.stringify({ error }) : ''}`,
isLoading: false,
}));
return;
}