Skip to content

Commit 33c5d33

Browse files
committed
feat: enhance error handling in LoginForm to provide specific feedback for Axios errors
1 parent bcd085a commit 33c5d33

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

web/src/modules/auth/components/client/LoginFrom.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,30 @@ export const LoginForm: FC = () => {
5050
duration: 20_000, // 20 seconds
5151
});
5252
} catch (error) {
53-
toast.error('An error occurred. Please try again later.');
53+
if ((error as any).isAxiosError) {
54+
const axiosError = error as any;
55+
56+
if (axiosError.response) {
57+
const { status } = axiosError.response;
58+
59+
if (status === 429) {
60+
toast.error('Too many requests. Please try again later.', {
61+
position: 'top-center',
62+
duration: 20_000, // 20 seconds
63+
});
64+
} else {
65+
toast.error('An unexpected error occurred', {
66+
position: 'top-center',
67+
duration: 20_000, // 20 seconds
68+
});
69+
}
70+
}
71+
} else {
72+
toast.error('An unexpected error occurred', {
73+
position: 'top-center',
74+
duration: 20_000, // 20 seconds
75+
});
76+
}
5477
} finally {
5578
setIsLoading(false);
5679
}

0 commit comments

Comments
 (0)