feat: Implement final error coverage

This commit is contained in:
gpt-engineer-app[bot]
2025-11-04 19:50:06 +00:00
parent a9334c7a3a
commit 0df047d56b
9 changed files with 291 additions and 403 deletions

View File

@@ -6,8 +6,7 @@ import type {
RideModelSubmissionData
} from '@/types/submission-data';
import { supabase } from '@/lib/supabaseClient';
import { logger } from './logger';
import { getErrorMessage } from './errorHandler';
import { handleNonCriticalError, getErrorMessage } from './errorHandler';
type SubmissionDataTypes =
| ParkSubmissionData
@@ -81,11 +80,9 @@ async function detectPhotoChanges(submissionId: string): Promise<PhotoChange[]>
.eq('submission_id', submissionId);
if (photoError) {
const errorMessage = getErrorMessage(photoError);
logger.error('Photo submission fetch failed', {
action: 'detect_photo_changes',
submissionId,
error: errorMessage
handleNonCriticalError(photoError, {
action: 'Detect Photo Changes (Fetch Photo Submission)',
metadata: { submissionId }
});
} else {
const photoSubmission = photoSubmissions?.[0];
@@ -109,11 +106,9 @@ async function detectPhotoChanges(submissionId: string): Promise<PhotoChange[]>
.in('item_type', ['photo_edit', 'photo_delete']);
if (itemsError) {
const errorMessage = getErrorMessage(itemsError);
logger.error('Submission items fetch failed', {
action: 'detect_photo_changes',
submissionId,
error: errorMessage
handleNonCriticalError(itemsError, {
action: 'Detect Photo Changes (Fetch Submission Items)',
metadata: { submissionId }
});
} else if (submissionItems && submissionItems.length > 0) {
for (const item of submissionItems) {
@@ -123,11 +118,9 @@ async function detectPhotoChanges(submissionId: string): Promise<PhotoChange[]>
}
}
} catch (err: unknown) {
const errorMessage = getErrorMessage(err);
logger.error('Photo change detection failed', {
action: 'detect_photo_changes',
submissionId,
error: errorMessage
handleNonCriticalError(err, {
action: 'Detect Photo Changes',
metadata: { submissionId }
});
}
@@ -349,7 +342,10 @@ export async function detectChanges(
if (data?.name) entityName = `${data.name} (${formatEntityType(entityType)})`;
}
} catch (err) {
logger.error('Error fetching entity name for photo operation', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
handleNonCriticalError(err, {
action: 'Fetch Entity Name for Photo Operation',
metadata: { entityType: itemData.entity_type, entityId: itemData.entity_id }
});
}
}
@@ -395,7 +391,10 @@ export async function detectChanges(
entityName = `${formatEntityType(entityType)} - ${itemData.title}`;
}
} catch (err) {
logger.error('Error fetching entity name for milestone', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
handleNonCriticalError(err, {
action: 'Fetch Entity Name for Milestone',
metadata: { entityType: itemData.entity_type, entityId: itemData.entity_id }
});
// Fall back to just the title if database lookup fails
if (itemData.title) {
entityName = itemData.title;
@@ -434,7 +433,10 @@ export async function detectChanges(
}
}
} catch (err) {
logger.error('Error resolving entity name for field display', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
handleNonCriticalError(err, {
action: 'Resolve Entity Name for Field Display',
metadata: { entityType: itemData.entity_type, entityId: itemData.entity_id }
});
}
// Add entity name as an explicit field change at the beginning