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

@@ -12,8 +12,7 @@ import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { handleError, handleSuccess, getErrorMessage } from '@/lib/errorHandler';
import { logger } from '@/lib/logger';
import { handleError, handleSuccess, handleNonCriticalError, getErrorMessage } from '@/lib/errorHandler';
interface UserProfile {
id: string;
@@ -131,7 +130,13 @@ export function ProfileManager() {
}
});
if (logError) logger.error('Failed to log admin action', { error: getErrorMessage(logError) });
if (logError) {
handleNonCriticalError(logError, {
action: 'Log admin action (ban/unban)',
userId: user?.id,
metadata: { targetUserId, ban, banReason }
});
}
handleSuccess(
'Success',
@@ -211,7 +216,13 @@ export function ProfileManager() {
_details: { role: newRole, previous_roles: currentRoles }
});
if (logError) logger.error('Failed to log admin action', { error: getErrorMessage(logError) });
if (logError) {
handleNonCriticalError(logError, {
action: 'Log admin action (role change)',
userId: user?.id,
metadata: { targetUserId, newRole, previousRoles: currentRoles }
});
}
handleSuccess('Success', 'User role updated successfully.');

View File

@@ -23,7 +23,7 @@ import { useAdminSettings } from '@/hooks/useAdminSettings';
import { useAuth } from '@/hooks/useAuth';
import { useIsMobile } from '@/hooks/use-mobile';
import { smartMergeArray } from '@/lib/smartStateUpdate';
import { handleError, handleSuccess } from '@/lib/errorHandler';
import { handleError, handleSuccess, handleNonCriticalError } from '@/lib/errorHandler';
// Type-safe reported content interfaces
interface ReportedReview {
@@ -383,7 +383,11 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
}
});
} catch (auditError) {
logger.error('Failed to log report action audit', { error: auditError });
handleNonCriticalError(auditError, {
action: 'Log report action audit',
userId: user?.id,
metadata: { reportId, action }
});
}
}