Fix error handling
This commit is contained in:
parent
26df4ba42f
commit
3e5135aa03
@ -55,18 +55,23 @@ const SignWithCosmos = () => {
|
||||
}),
|
||||
});
|
||||
|
||||
if (response.status === 429) {
|
||||
const errorResponse = await response.json();
|
||||
enqueueSnackbar(`${response.statusText} : ${errorResponse.error}`, { variant: "error" });
|
||||
setIsRequesting(false);
|
||||
throw new Error('Failed to send request');
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user