mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 03:11:13 -05:00
Implement Phase 3C error logging
This commit is contained in:
@@ -2,8 +2,7 @@ import { useState, useEffect } from 'react';
|
||||
import { supabase } from '@/lib/supabaseClient';
|
||||
import { ComboboxOption } from '@/components/ui/combobox';
|
||||
import { toast } from 'sonner';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||
|
||||
export function useCountries() {
|
||||
const [countries, setCountries] = useState<ComboboxOption[]>([]);
|
||||
@@ -31,8 +30,7 @@ export function useCountries() {
|
||||
}))
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to fetch countries', { error: errorMsg });
|
||||
handleNonCriticalError(error, { action: 'Fetch countries' });
|
||||
toast.error('Failed to load countries', {
|
||||
description: 'Please refresh the page and try again.',
|
||||
});
|
||||
@@ -80,8 +78,10 @@ export function useStatesProvinces(country?: string) {
|
||||
}))
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to fetch states/provinces', { country, error: errorMsg });
|
||||
handleNonCriticalError(error, {
|
||||
action: 'Fetch states/provinces',
|
||||
metadata: { country },
|
||||
});
|
||||
toast.error('Failed to load states/provinces', {
|
||||
description: 'Please refresh the page and try again.',
|
||||
});
|
||||
@@ -120,8 +120,7 @@ export function useManufacturers() {
|
||||
}))
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to fetch manufacturers', { error: errorMsg });
|
||||
handleNonCriticalError(error, { action: 'Fetch manufacturers' });
|
||||
toast.error('Failed to load manufacturers', {
|
||||
description: 'Please refresh the page and try again.',
|
||||
});
|
||||
@@ -165,8 +164,10 @@ export function useRideModels(manufacturerId?: string) {
|
||||
}))
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to fetch ride models', { manufacturerId, error: errorMsg });
|
||||
handleNonCriticalError(error, {
|
||||
action: 'Fetch ride models',
|
||||
metadata: { manufacturerId },
|
||||
});
|
||||
toast.error('Failed to load ride models', {
|
||||
description: 'Please refresh the page and try again.',
|
||||
});
|
||||
@@ -208,8 +209,7 @@ export function useCompanyHeadquarters() {
|
||||
}))
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to fetch headquarters', { error: errorMsg });
|
||||
handleNonCriticalError(error, { action: 'Fetch headquarters' });
|
||||
toast.error('Failed to load headquarters', {
|
||||
description: 'Please refresh the page and try again.',
|
||||
});
|
||||
@@ -248,8 +248,7 @@ export function useOperators() {
|
||||
}))
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to fetch operators', { error: errorMsg });
|
||||
handleNonCriticalError(error, { action: 'Fetch operators' });
|
||||
toast.error('Failed to load operators', {
|
||||
description: 'Please refresh the page and try again.',
|
||||
});
|
||||
@@ -288,8 +287,7 @@ export function usePropertyOwners() {
|
||||
}))
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to fetch property owners', { error: errorMsg });
|
||||
handleNonCriticalError(error, { action: 'Fetch property owners' });
|
||||
toast.error('Failed to load property owners', {
|
||||
description: 'Please refresh the page and try again.',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user