Refactor: Implement complete type safety plan

This commit is contained in:
gpt-engineer-app[bot]
2025-10-16 14:39:42 +00:00
parent 88e89e0a65
commit 8d26ac0749
10 changed files with 239 additions and 12 deletions

View File

@@ -61,3 +61,16 @@ export const handleInfo = (
duration: 4000
});
};
/**
* Type-safe error message extraction utility
* Use this instead of `error: any` in catch blocks
*/
export const getErrorMessage = (error: unknown): string => {
if (error instanceof Error) return error.message;
if (typeof error === 'string') return error;
if (error && typeof error === 'object' && 'message' in error) {
return String(error.message);
}
return 'An unexpected error occurred';
};