Spaces:
No application file
No application file
File size: 1,708 Bytes
f132e93 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /**
* Real Console API Logger for RiShre Platform
* Ensures full diagnostic error traces appear in the real browser console (DevTools)
*/
export interface ApiErrorContext {
topic: string;
endpoint: string;
model?: string;
status?: number;
statusText?: string;
message: string;
requestPayload?: unknown;
rawResponse?: unknown;
error?: unknown;
}
/**
* Emits a structured, high-visibility error log directly to the real browser console
*/
export function logRealConsoleApiError(context: ApiErrorContext): void {
const timestamp = new Date().toISOString();
const title = `[RiShre API Error] ${context.topic} (${context.status ? `HTTP ${context.status}` : 'Exception'})`;
// Use styled real console logging for immediate visibility in DevTools
console.group(
`%c${title}%c @ ${timestamp}`,
'background: #dc2626; color: #ffffff; padding: 3px 8px; border-radius: 4px; font-weight: 800; font-family: monospace;',
'color: #f87171; font-weight: normal; margin-left: 6px;'
);
console.error(`🚨 Topic: ${context.topic}`);
console.error(`📍 Endpoint: ${context.endpoint}`);
if (context.model) console.error(`🤖 Model: ${context.model}`);
if (context.status) console.error(`📊 Status Code: ${context.status} ${context.statusText ? `(${context.statusText})` : ''}`);
console.error(`💬 Error Message: ${context.message}`);
if (context.requestPayload) {
console.error('📦 Request Context:', context.requestPayload);
}
if (context.rawResponse) {
console.error('📄 Raw Response / Body:', context.rawResponse);
}
if (context.error) {
console.error('💥 Original Exception / Stack:', context.error);
}
console.groupEnd();
}
|