diff --git a/src/utils/errorHandling.ts b/src/utils/errorHandling.ts index 3a6e561..4a8689f 100644 --- a/src/utils/errorHandling.ts +++ b/src/utils/errorHandling.ts @@ -1,5 +1,13 @@ +/** + * Error Handling Utilities + * Centralized error handling and custom error types + */ + import { trackEvent } from './analytics'; +/** + * Custom application error class with error codes, severity levels, and metadata + */ export class AppError extends Error { constructor( message: string, @@ -12,6 +20,9 @@ export class AppError extends Error { } } +/** + * Standard error codes used throughout the application + */ export const errorCodes = { NETWORK_ERROR: 'ERR_NETWORK', API_ERROR: 'ERR_API', @@ -20,6 +31,9 @@ export const errorCodes = { UNKNOWN_ERROR: 'ERR_UNKNOWN' } as const; +/** + * Handle and normalize errors with tracking and logging + */ export const handleError = (error: unknown, context: string) => { let appError: AppError; @@ -52,6 +66,9 @@ export const handleError = (error: unknown, context: string) => { return appError; }; +/** + * Create an API error with HTTP status code + */ export const createAPIError = (status: number, message: string) => { return new AppError( message,