mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -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:
@@ -13,6 +13,7 @@ import {
|
||||
extractSpanContextFromHeaders,
|
||||
type Span
|
||||
} from '../_shared/logger.ts';
|
||||
import { formatEdgeError, toError } from '../_shared/errorFormatter.ts';
|
||||
|
||||
const SUPABASE_URL = Deno.env.get('SUPABASE_URL') || 'https://api.thrillwiki.com';
|
||||
const SUPABASE_ANON_KEY = Deno.env.get('SUPABASE_ANON_KEY')!;
|
||||
@@ -277,7 +278,7 @@ const handler = async (req: Request) => {
|
||||
}
|
||||
|
||||
if (idempotencyError) {
|
||||
throw idempotencyError;
|
||||
throw toError(idempotencyError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +402,7 @@ const handler = async (req: Request) => {
|
||||
requestId,
|
||||
idempotencyKey,
|
||||
status: 'failed',
|
||||
error: updateError instanceof Error ? updateError.message : String(updateError),
|
||||
error: formatEdgeError(updateError),
|
||||
action: 'process_approval'
|
||||
});
|
||||
// Non-blocking - continue with error response even if idempotency update fails
|
||||
@@ -461,7 +462,7 @@ const handler = async (req: Request) => {
|
||||
requestId,
|
||||
idempotencyKey,
|
||||
status: 'completed',
|
||||
error: updateError instanceof Error ? updateError.message : String(updateError),
|
||||
error: formatEdgeError(updateError),
|
||||
action: 'process_approval'
|
||||
});
|
||||
// Non-blocking - transaction succeeded, so continue with success response
|
||||
@@ -483,13 +484,13 @@ const handler = async (req: Request) => {
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
endSpan(rootSpan, 'error', error instanceof Error ? error : new Error(String(error)));
|
||||
endSpan(rootSpan, 'error', error instanceof Error ? error : toError(error));
|
||||
logSpan(rootSpan);
|
||||
|
||||
edgeLogger.error('Unexpected error', {
|
||||
requestId,
|
||||
duration: rootSpan.duration,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
error: formatEdgeError(error),
|
||||
stack: error instanceof Error ? error.stack : undefined,
|
||||
action: 'process_approval'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user