mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 15:31: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:
@@ -3,6 +3,8 @@
|
||||
* Prevents sensitive data exposure and provides consistent log format
|
||||
*/
|
||||
|
||||
import { formatEdgeError } from './errorFormatter.ts';
|
||||
|
||||
type LogLevel = 'info' | 'warn' | 'error' | 'debug';
|
||||
|
||||
interface LogContext {
|
||||
@@ -96,16 +98,17 @@ export function startSpan(
|
||||
/**
|
||||
* End a span with final status
|
||||
*/
|
||||
export function endSpan(span: Span, status?: 'ok' | 'error', error?: Error): Span {
|
||||
export function endSpan(span: Span, status?: 'ok' | 'error', error?: unknown): Span {
|
||||
span.endTime = Date.now();
|
||||
span.duration = span.endTime - span.startTime;
|
||||
span.status = status || 'ok';
|
||||
|
||||
if (error) {
|
||||
const err = error instanceof Error ? error : new Error(formatEdgeError(error));
|
||||
span.error = {
|
||||
type: error.name,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
type: err.name,
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user