mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 20:31:12 -05:00
Refactor: Implement full error logging
This commit is contained in:
@@ -6,7 +6,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { MapPin, Loader2, X } from 'lucide-react';
|
||||
import { ParkLocationMap } from '@/components/maps/ParkLocationMap';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||
|
||||
interface LocationResult {
|
||||
place_id: number;
|
||||
@@ -102,7 +102,6 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
||||
// Check if response is OK and content-type is JSON
|
||||
if (!response.ok) {
|
||||
const errorMsg = `Location search failed (${response.status}). Please try again.`;
|
||||
logger.error('OpenStreetMap API error', { status: response.status });
|
||||
setSearchError(errorMsg);
|
||||
setResults([]);
|
||||
setShowResults(false);
|
||||
@@ -112,7 +111,6 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (!contentType || !contentType.includes('application/json')) {
|
||||
const errorMsg = 'Invalid response from location service. Please try again.';
|
||||
logger.error('Invalid response format from OpenStreetMap', { contentType });
|
||||
setSearchError(errorMsg);
|
||||
setResults([]);
|
||||
setShowResults(false);
|
||||
@@ -123,8 +121,11 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
||||
setResults(data);
|
||||
setShowResults(true);
|
||||
setSearchError(null);
|
||||
} catch {
|
||||
logger.error('Location search failed', { query: searchQuery });
|
||||
} catch (error: unknown) {
|
||||
handleNonCriticalError(error, {
|
||||
action: 'Search locations',
|
||||
metadata: { query: searchQuery }
|
||||
});
|
||||
setSearchError('Failed to search locations. Please check your connection.');
|
||||
setResults([]);
|
||||
setShowResults(false);
|
||||
|
||||
Reference in New Issue
Block a user