auto-claude: subtask-1-1 - Add JSDoc to errorHandling.ts (AppError class, han
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Error Handling Utilities
|
||||||
|
* Centralized error handling and custom error types
|
||||||
|
*/
|
||||||
|
|
||||||
import { trackEvent } from './analytics';
|
import { trackEvent } from './analytics';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom application error class with error codes, severity levels, and metadata
|
||||||
|
*/
|
||||||
export class AppError extends Error {
|
export class AppError extends Error {
|
||||||
constructor(
|
constructor(
|
||||||
message: string,
|
message: string,
|
||||||
@@ -12,6 +20,9 @@ export class AppError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard error codes used throughout the application
|
||||||
|
*/
|
||||||
export const errorCodes = {
|
export const errorCodes = {
|
||||||
NETWORK_ERROR: 'ERR_NETWORK',
|
NETWORK_ERROR: 'ERR_NETWORK',
|
||||||
API_ERROR: 'ERR_API',
|
API_ERROR: 'ERR_API',
|
||||||
@@ -20,6 +31,9 @@ export const errorCodes = {
|
|||||||
UNKNOWN_ERROR: 'ERR_UNKNOWN'
|
UNKNOWN_ERROR: 'ERR_UNKNOWN'
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle and normalize errors with tracking and logging
|
||||||
|
*/
|
||||||
export const handleError = (error: unknown, context: string) => {
|
export const handleError = (error: unknown, context: string) => {
|
||||||
let appError: AppError;
|
let appError: AppError;
|
||||||
|
|
||||||
@@ -52,6 +66,9 @@ export const handleError = (error: unknown, context: string) => {
|
|||||||
return appError;
|
return appError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an API error with HTTP status code
|
||||||
|
*/
|
||||||
export const createAPIError = (status: number, message: string) => {
|
export const createAPIError = (status: number, message: string) => {
|
||||||
return new AppError(
|
return new AppError(
|
||||||
message,
|
message,
|
||||||
|
|||||||
Reference in New Issue
Block a user