mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 21:31:14 -05:00
Refactor: Implement full error logging
This commit is contained in:
@@ -15,7 +15,6 @@ import { toast } from '@/hooks/use-toast';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
export interface UploadedImage {
|
||||
url: string;
|
||||
@@ -71,8 +70,8 @@ export function EntityMultiImageUploader({
|
||||
if (image.isLocal && image.url.startsWith('blob:')) {
|
||||
try {
|
||||
URL.revokeObjectURL(image.url);
|
||||
} catch (error: unknown) {
|
||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
||||
} catch {
|
||||
// Silent cleanup failure - non-critical
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,7 +18,6 @@ import { supabase } from '@/lib/supabaseClient';
|
||||
import { EntityPhotoGalleryProps } from '@/types/submissions';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface Photo {
|
||||
id: string;
|
||||
@@ -74,7 +73,7 @@ export function EntityPhotoGallery({
|
||||
|
||||
setPhotos(mappedPhotos);
|
||||
} catch (error: unknown) {
|
||||
logger.error('Failed to fetch photos', { error: getErrorMessage(error), entityId, entityType });
|
||||
// Photo fetch failed - display empty gallery
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import { useToast } from '@/hooks/use-toast';
|
||||
import { Trash2, Pencil } from 'lucide-react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface Photo {
|
||||
id: string;
|
||||
@@ -127,8 +126,8 @@ export function PhotoManagementDialog({
|
||||
const { data } = await supabase.from('companies').select('name').eq('id', entityId).single();
|
||||
if (data?.name) entityName = data.name;
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error('Failed to fetch entity name', { error: getErrorMessage(err), entityType, entityId });
|
||||
} catch {
|
||||
// Failed to fetch entity name - use default
|
||||
}
|
||||
|
||||
// Create content submission
|
||||
|
||||
@@ -17,7 +17,6 @@ import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { supabase } from '@/lib/supabaseClient';
|
||||
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface PhotoUploadProps {
|
||||
onUploadComplete?: (urls: string[], imageId?: string) => void;
|
||||
@@ -71,8 +70,8 @@ export function PhotoUpload({
|
||||
objectUrlsRef.current.forEach(url => {
|
||||
try {
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (error: unknown) {
|
||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
||||
} catch {
|
||||
// Silent cleanup failure - non-critical
|
||||
}
|
||||
});
|
||||
objectUrlsRef.current.clear();
|
||||
@@ -90,8 +89,8 @@ export function PhotoUpload({
|
||||
try {
|
||||
URL.revokeObjectURL(url);
|
||||
objectUrlsRef.current.delete(url);
|
||||
} catch (error: unknown) {
|
||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
||||
} catch {
|
||||
// Silent cleanup failure - non-critical
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -194,8 +193,8 @@ export function PhotoUpload({
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
logger.error('Status poll error', { error: getErrorMessage(error) });
|
||||
} catch {
|
||||
// Status poll error - will retry
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
@@ -249,8 +248,8 @@ export function PhotoUpload({
|
||||
undefined,
|
||||
'DELETE'
|
||||
);
|
||||
} catch (deleteError) {
|
||||
logger.warn('Failed to delete old avatar');
|
||||
} catch {
|
||||
// Old avatar deletion failed - non-critical
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +338,6 @@ export function PhotoUpload({
|
||||
alt="Avatar"
|
||||
className="w-24 h-24 rounded-full object-cover border-2 border-border"
|
||||
onError={(e) => {
|
||||
logger.warn('Failed to load avatar image');
|
||||
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
||||
}}
|
||||
/>
|
||||
@@ -487,7 +485,6 @@ export function PhotoUpload({
|
||||
alt={image.filename}
|
||||
className="w-full aspect-square object-cover rounded-lg border"
|
||||
onError={(e) => {
|
||||
logger.warn('Failed to load thumbnail image');
|
||||
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user