Fix error handling

This commit is contained in:
IshaVenikar 2024-07-15 17:07:29 +05:30 committed by Adw8
parent 26df4ba42f
commit 3e5135aa03

View File

@ -55,18 +55,23 @@ const SignWithCosmos = () => {
}),
});
if (response.ok) {
enqueueSnackbar('Tokens sent successfully', { variant: "success" });
} else {
if (response.status === 429) {
const errorResponse = await response.json();
enqueueSnackbar(`${response.statusText} : ${errorResponse.error}`, { variant: "error" });
setIsRequesting(false);
} else {
throw new Error('Failed to send request');
}
}
getBalances();
setIsRequesting(false);
enqueueSnackbar('Tokens sent successfully', { variant: "success" });
} catch (error) {
console.error('Error:', error);
throw error;
}
};