Refactor: Implement full error logging

This commit is contained in:
gpt-engineer-app[bot]
2025-11-04 19:11:24 +00:00
parent 6e64b80106
commit e74c2acbd4
11 changed files with 48 additions and 186 deletions

View File

@@ -5,7 +5,7 @@ import { Label } from '@/components/ui/label';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Alert, AlertDescription } from '@/components/ui/alert';
import { Badge } from '@/components/ui/badge';
import { handleError, handleSuccess, handleInfo, AppError, getErrorMessage } from '@/lib/errorHandler';
import { handleError, handleSuccess, handleInfo, handleNonCriticalError, AppError, getErrorMessage } from '@/lib/errorHandler';
import { logger } from '@/lib/logger';
import { useAuth } from '@/hooks/useAuth';
import { useRequireMFA } from '@/hooks/useRequireMFA';
@@ -51,10 +51,10 @@ export function TOTPSetup() {
}));
setFactors(totpFactors);
} catch (error: unknown) {
logger.error('Failed to fetch TOTP factors', {
handleNonCriticalError(error, {
action: 'Fetch TOTP factors',
userId: user?.id,
action: 'fetch_totp_factors',
error: getErrorMessage(error)
metadata: { context: 'initial_load' }
});
}
};
@@ -76,11 +76,6 @@ export function TOTPSetup() {
setFactorId(data.id);
setEnrolling(true);
} catch (error: unknown) {
logger.error('Failed to start TOTP enrollment', {
userId: user?.id,
action: 'totp_enroll_start',
error: getErrorMessage(error)
});
handleError(
new AppError(
getErrorMessage(error) || 'Failed to start TOTP enrollment',
@@ -148,13 +143,6 @@ export function TOTPSetup() {
}, 2000);
}
} catch (error: unknown) {
logger.error('TOTP verification failed', {
userId: user?.id,
action: 'totp_verify',
error: getErrorMessage(error),
factorId
});
handleError(
new AppError(
getErrorMessage(error) || 'Invalid verification code. Please try again.',