mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 09:31:13 -05:00
Refactor: Implement complete type safety plan
This commit is contained in:
@@ -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';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user