Fix error handling

This commit is contained in:
gpt-engineer-app[bot]
2025-11-05 00:54:12 +00:00
parent df9f997c64
commit 5985ee352d
4 changed files with 41 additions and 25 deletions

View File

@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
import { supabase } from '@/lib/supabaseClient';
import { useAuth } from './useAuth';
import { useToast } from './use-toast';
import { getErrorMessage, handleNonCriticalError } from '@/lib/errorHandler';
import { getErrorMessage, handleNonCriticalError, handleError } from '@/lib/errorHandler';
import { getSubmissionTypeLabel } from '@/lib/moderation/entities';
import { logger } from '@/lib/logger';
@@ -195,7 +195,7 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
// Start countdown timer for restored lock
startLockTimer(expiresAt);
console.log('Lock state restored from database', {
logger.info('Lock state restored from database', {
submissionId: data.id,
expiresAt: expiresAt.toISOString(),
});
@@ -203,8 +203,8 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
}
} catch (error: unknown) {
// Log but don't show user toast (they haven't taken any action yet)
console.debug('Failed to restore lock state', {
error: error instanceof Error ? error.message : String(error),
logger.debug('Failed to restore lock state', {
error: getErrorMessage(error),
userId: user.id,
});
}
@@ -608,10 +608,10 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
return data;
} catch (error: unknown) {
toast({
title: 'Failed to Release Lock',
description: getErrorMessage(error),
variant: 'destructive',
handleError(error, {
action: 'Superuser Release Lock',
userId: user.id,
metadata: { submissionId }
});
return false;
} finally {
@@ -647,10 +647,10 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
return count;
} catch (error: unknown) {
toast({
title: 'Failed to Clear Locks',
description: getErrorMessage(error),
variant: 'destructive',
handleError(error, {
action: 'Superuser Clear All Locks',
userId: user.id,
metadata: { attemptedAction: 'bulk_release' }
});
return 0;
} finally {