Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pmoves/ui/lib/constants/errorIds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Error ID constants for log aggregation (Loki/Promtail).
* Each unique error type gets a stable ID for tracking and alerting.
*
* Usage: logError(message, error, 'error', { errorId: ErrorIds.TOKENISM_SIMULATION_FAILED, ... })
*/

export const ErrorIds = {
// Tokenism Service Errors
TOKENISM_SIMULATION_FAILED: 'tokenism_simulation_failed',
TOKENISM_GEOMETRY_LOAD_FAILED: 'tokenism_geometry_load_failed',
TOKENISM_HEALTH_CHECK_FAILED: 'tokenism_health_check_failed',
TOKENISM_API_ERROR: 'tokenism_api_error',

// Network Errors
NETWORK_TIMEOUT: 'network_timeout',
NETWORK_CONNECTION_REFUSED: 'network_connection_refused',
NETWORK_OFFLINE: 'network_offline',

// Data Validation Errors
INVALID_SIMULATION_RESULT: 'invalid_simulation_result',
MISSING_WEEKLY_METRICS: 'missing_weekly_metrics',
INVALID_METRICS_DATA: 'invalid_metrics_data',

// UI Errors
CANVAS_RENDER_FAILED: 'canvas_render_failed',
VISUALIZATION_FALLBACK: 'visualization_fallback',
} as const;

export type ErrorId = typeof ErrorIds[keyof typeof ErrorIds];
4 changes: 4 additions & 0 deletions pmoves/ui/lib/errorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
* Provides consistent error logging and user feedback
*/

import type { ErrorId } from './constants/errorIds';

type ErrorSeverity = 'debug' | 'info' | 'warning' | 'error' | 'critical';

interface ErrorContext {
/** Stable error ID for log aggregation */
errorId?: ErrorId;
component?: string;
action?: string;
userId?: string;
Expand Down