Fix critical path catch blocks

This commit is contained in:
gpt-engineer-app[bot]
2025-10-21 15:32:01 +00:00
parent 05ba99e368
commit 5e789c7b4b
14 changed files with 33 additions and 33 deletions

View File

@@ -109,7 +109,7 @@ export const ModerationQueue = forwardRef<ModerationQueueRef, ModerationQueuePro
variant: 'destructive', variant: 'destructive',
}); });
} }
} catch (error) { } catch (error: unknown) {
console.error('Error fetching items for edit:', error); console.error('Error fetching items for edit:', error);
toast({ toast({
title: 'Error', title: 'Error',

View File

@@ -82,7 +82,7 @@ export function PhotoSubmissionDisplay({ submissionId }: PhotoSubmissionDisplayP
setPhotos(data || []); setPhotos(data || []);
console.log(`✅ Successfully loaded ${data?.length || 0} photos`); console.log(`✅ Successfully loaded ${data?.length || 0} photos`);
} catch (error) { } catch (error: unknown) {
const errorMsg = getErrorMessage(error); const errorMsg = getErrorMessage(error);
console.error('❌ PhotoSubmissionDisplay error:', errorMsg); console.error('❌ PhotoSubmissionDisplay error:', errorMsg);
setPhotos([]); setPhotos([]);

View File

@@ -68,7 +68,7 @@ export function ReportButton({ entityType, entityId, className }: ReportButtonPr
setOpen(false); setOpen(false);
setReportType(''); setReportType('');
setReason(''); setReason('');
} catch (error) { } catch (error: unknown) {
console.error('Error submitting report:', error); console.error('Error submitting report:', error);
toast({ toast({
title: "Error", title: "Error",

View File

@@ -121,7 +121,7 @@ export function UserRoleManager() {
const existingUserIds = userRoles.map(ur => ur.user_id); const existingUserIds = userRoles.map(ur => ur.user_id);
const filteredResults = (data || []).filter(profile => !existingUserIds.includes(profile.user_id)); const filteredResults = (data || []).filter(profile => !existingUserIds.includes(profile.user_id));
setSearchResults(filteredResults); setSearchResults(filteredResults);
} catch (error) { } catch (error: unknown) {
console.error('Error searching users:', error); console.error('Error searching users:', error);
} }
}; };

View File

@@ -143,7 +143,7 @@ export function AccountProfileTab() {
await refreshProfile(); await refreshProfile();
handleSuccess('Profile updated', 'Your profile has been successfully updated.'); handleSuccess('Profile updated', 'Your profile has been successfully updated.');
} catch (error) { } catch (error: unknown) {
handleError(error, { action: 'Update profile', userId: user.id }); handleError(error, { action: 'Update profile', userId: user.id });
} finally { } finally {
setLoading(false); setLoading(false);
@@ -204,7 +204,7 @@ export function AccountProfileTab() {
setShowCancelEmailDialog(false); setShowCancelEmailDialog(false);
await refreshProfile(); await refreshProfile();
} catch (error) { } catch (error: unknown) {
handleError(error, { action: 'Cancel email change' }); handleError(error, { action: 'Cancel email change' });
} finally { } finally {
setCancellingEmail(false); setCancellingEmail(false);

View File

@@ -41,7 +41,7 @@ export function DeletionStatusBanner({ scheduledDate, onCancelled }: DeletionSta
}); });
onCancelled(); onCancelled();
} catch (error) { } catch (error: unknown) {
const errorMsg = getErrorMessage(error); const errorMsg = getErrorMessage(error);
toast({ toast({
variant: 'destructive', variant: 'destructive',

View File

@@ -49,7 +49,7 @@ export function SimplePhotoUpload({ onUpload, disabled, children }: SimplePhotoU
title: 'Image uploaded', title: 'Image uploaded',
description: 'Your image has been uploaded successfully' description: 'Your image has been uploaded successfully'
}); });
} catch (error) { } catch (error: unknown) {
toast({ toast({
title: 'Upload failed', title: 'Upload failed',
description: getErrorMessage(error), description: getErrorMessage(error),

View File

@@ -67,7 +67,7 @@ export function EntityMultiImageUploader({
if (image.isLocal && image.url.startsWith('blob:')) { if (image.isLocal && image.url.startsWith('blob:')) {
try { try {
URL.revokeObjectURL(image.url); URL.revokeObjectURL(image.url);
} catch (error) { } catch (error: unknown) {
console.error('Error revoking object URL:', error); console.error('Error revoking object URL:', error);
} }
} }
@@ -105,7 +105,7 @@ export function EntityMultiImageUploader({
banner_assignment: bannerIndex >= 0 ? bannerIndex : null, banner_assignment: bannerIndex >= 0 ? bannerIndex : null,
card_assignment: cardIndex >= 0 ? cardIndex : null, card_assignment: cardIndex >= 0 ? cardIndex : null,
}); });
} catch (error) { } catch (error: unknown) {
console.error('Failed to load entity photos:', error); console.error('Failed to load entity photos:', error);
toast({ toast({
title: 'Error', title: 'Error',

View File

@@ -76,7 +76,7 @@ export function EntityPhotoGallery({
console.log('📷 [FETCH PHOTOS] Mapped photos:', mappedPhotos); console.log('📷 [FETCH PHOTOS] Mapped photos:', mappedPhotos);
setPhotos(mappedPhotos); setPhotos(mappedPhotos);
} catch (error) { } catch (error: unknown) {
console.error('📷 [FETCH PHOTOS] Error:', error); console.error('📷 [FETCH PHOTOS] Error:', error);
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -77,7 +77,7 @@ export function PhotoManagementDialog({
if (error) throw error; if (error) throw error;
setPhotos(data || []); setPhotos(data || []);
} catch (error) { } catch (error: unknown) {
console.error('Error fetching photos:', error); console.error('Error fetching photos:', error);
toast({ toast({
title: 'Error', title: 'Error',
@@ -172,7 +172,7 @@ export function PhotoManagementDialog({
setPhotoToDelete(null); setPhotoToDelete(null);
setDeleteReason(''); setDeleteReason('');
onOpenChange(false); onOpenChange(false);
} catch (error) { } catch (error: unknown) {
console.error('Error requesting photo deletion:', error); console.error('Error requesting photo deletion:', error);
toast({ toast({
title: 'Error', title: 'Error',
@@ -237,7 +237,7 @@ export function PhotoManagementDialog({
description: 'Your photo edit has been submitted for moderation', description: 'Your photo edit has been submitted for moderation',
}); });
onOpenChange(false); onOpenChange(false);
} catch (error) { } catch (error: unknown) {
console.error('Error requesting photo edit:', error); console.error('Error requesting photo edit:', error);
toast({ toast({
title: 'Error', title: 'Error',

View File

@@ -66,17 +66,17 @@ export function PhotoUpload({
const canUploadMore = totalImages < actualMaxFiles; const canUploadMore = totalImages < actualMaxFiles;
useEffect(() => { useEffect(() => {
return () => { return () => {
objectUrlsRef.current.forEach(url => { objectUrlsRef.current.forEach(url => {
try { try {
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
} catch (error) { } catch (error: unknown) {
console.error('Error revoking object URL:', error); console.error('Error revoking object URL:', error);
} }
}); });
objectUrlsRef.current.clear(); objectUrlsRef.current.clear();
}; };
}, []); }, []);
const createObjectUrl = (file: File): string => { const createObjectUrl = (file: File): string => {
const url = URL.createObjectURL(file); const url = URL.createObjectURL(file);
@@ -89,7 +89,7 @@ export function PhotoUpload({
try { try {
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
objectUrlsRef.current.delete(url); objectUrlsRef.current.delete(url);
} catch (error) { } catch (error: unknown) {
console.error('Error revoking object URL:', error); console.error('Error revoking object URL:', error);
} }
} }
@@ -194,7 +194,7 @@ export function PhotoUpload({
}; };
} }
} }
} catch (error) { } catch (error: unknown) {
console.error('Status poll error:', error); console.error('Status poll error:', error);
} }
@@ -204,7 +204,7 @@ export function PhotoUpload({
revokeObjectUrl(previewUrl); revokeObjectUrl(previewUrl);
throw new Error('Upload timeout - image processing took too long'); throw new Error('Upload timeout - image processing took too long');
} catch (error) { } catch (error: unknown) {
revokeObjectUrl(previewUrl); revokeObjectUrl(previewUrl);
throw error; throw error;
} }
@@ -273,7 +273,7 @@ export function PhotoUpload({
} }
setUploadProgress(100); setUploadProgress(100);
} catch (error) { } catch (error: unknown) {
previewUrls.forEach(url => revokeObjectUrl(url)); previewUrls.forEach(url => revokeObjectUrl(url));
const errorMsg = getErrorMessage(error); const errorMsg = getErrorMessage(error);
setError(errorMsg); setError(errorMsg);

View File

@@ -167,7 +167,7 @@ export function UppyPhotoSubmissionUpload({
p === photo ? { ...p, url: cloudflareUrl, uploadStatus: 'uploaded' as const } : p p === photo ? { ...p, url: cloudflareUrl, uploadStatus: 'uploaded' as const } : p
)); ));
} catch (error) { } catch (error: unknown) {
console.error('Upload error:', error); console.error('Upload error:', error);
setPhotos(prev => prev.map(p => setPhotos(prev => prev.map(p =>
p === photo ? { ...p, uploadStatus: 'failed' as const } : p p === photo ? { ...p, uploadStatus: 'failed' as const } : p
@@ -255,7 +255,7 @@ export function UppyPhotoSubmissionUpload({
setTitle(''); setTitle('');
setPhotos([]); setPhotos([]);
onSubmissionComplete?.(); onSubmissionComplete?.();
} catch (error) { } catch (error: unknown) {
console.error('Submission error:', error); console.error('Submission error:', error);
toast({ toast({
variant: 'destructive', variant: 'destructive',

View File

@@ -200,7 +200,7 @@ export function UppyPhotoUpload({
const url = await uploadSingleFile(file); const url = await uploadSingleFile(file);
newUrls.push(url); newUrls.push(url);
setUploadProgress(Math.round(((i + 1) / totalFiles) * 100)); setUploadProgress(Math.round(((i + 1) / totalFiles) * 100));
} catch (error) { } catch (error: unknown) {
console.error(`Upload failed for ${file.name}:`, error); console.error(`Upload failed for ${file.name}:`, error);
toast({ toast({
variant: 'destructive', variant: 'destructive',

View File

@@ -49,7 +49,7 @@ export const useAvatarUpload = (
handleSuccess('Avatar updated', 'Your avatar has been successfully updated.'); handleSuccess('Avatar updated', 'Your avatar has been successfully updated.');
return { success: true }; return { success: true };
} catch (error) { } catch (error: unknown) {
// Rollback on error // Rollback on error
setState({ setState({
url: initialUrl, url: initialUrl,