mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 18:31:12 -05:00
Improve error reporting for location detection to include status codes
Update the detect-location Supabase function to return a 500 status code and an error message on failure, improving debugging and error monitoring. Replit-Commit-Author: Agent Replit-Commit-Session-Id: fe5b902e-beda-40fc-bf87-a3c4ab300e3a Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -79,7 +79,8 @@ serve(async (req) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error detecting location:', error);
|
console.error('Error detecting location:', error);
|
||||||
|
|
||||||
// Return default (metric) on error
|
// Return default (metric) with 500 status to indicate error occurred
|
||||||
|
// This allows proper error monitoring while still providing fallback data
|
||||||
const defaultResult: IPLocationResponse = {
|
const defaultResult: IPLocationResponse = {
|
||||||
country: 'Unknown',
|
country: 'Unknown',
|
||||||
countryCode: 'XX',
|
countryCode: 'XX',
|
||||||
@@ -87,13 +88,17 @@ serve(async (req) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify(defaultResult),
|
JSON.stringify({
|
||||||
|
...defaultResult,
|
||||||
|
error: error instanceof Error ? error.message : 'Failed to detect location',
|
||||||
|
fallback: true
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
...corsHeaders,
|
...corsHeaders,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
status: 200 // Return 200 even on error to provide fallback
|
status: 500
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user