mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 17:51:12 -05:00
Connect to Lovable Cloud
Add centralized errorFormatter to convert various error types into readable messages, and apply it across edge functions. Replace String(error) usage with formatEdgeError, update relevant imports, fix a throw to use toError, and enhance logger to log formatted errors. Includes new errorFormatter.ts and widespread updates to 18+ edge functions plus logger integration.
This commit is contained in:
@@ -2,6 +2,7 @@ import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
|
||||
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
|
||||
import { edgeLogger, startRequest, endRequest } from '../_shared/logger.ts'
|
||||
import { rateLimiters, withRateLimit } from '../_shared/rateLimiter.ts'
|
||||
import { formatEdgeError } from '../_shared/errorFormatter.ts'
|
||||
|
||||
// Environment-aware CORS configuration
|
||||
const getAllowedOrigin = (requestOrigin: string | null): string | null => {
|
||||
@@ -94,7 +95,7 @@ async function reportBanEvasionToAlerts(
|
||||
} catch (error) {
|
||||
// Non-blocking - log but don't fail the response
|
||||
edgeLogger.warn('Failed to report ban evasion', {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
error: formatEdgeError(error),
|
||||
requestId
|
||||
});
|
||||
}
|
||||
@@ -227,8 +228,8 @@ serve(withRateLimit(async (req) => {
|
||||
try {
|
||||
requestBody = await req.json();
|
||||
} catch (error: unknown) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
edgeLogger.error('Invalid JSON in delete request', {
|
||||
const errorMessage = formatEdgeError(error);
|
||||
edgeLogger.error('Invalid JSON in delete request', {
|
||||
error: errorMessage,
|
||||
requestId: tracking.requestId
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user