Handle error using snackbar
This commit is contained in:
parent
f7c88e883f
commit
920190d367
@ -58,20 +58,20 @@ const SignWithCosmos = () => {
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
enqueueSnackbar('Tokens sent successfully', { variant: "success" });
|
enqueueSnackbar('Tokens sent successfully', { variant: "success" });
|
||||||
} else {
|
} else {
|
||||||
|
const errorResponse = await response.json();
|
||||||
if (response.status === 429) {
|
if (response.status === 429) {
|
||||||
const errorResponse = await response.json();
|
|
||||||
enqueueSnackbar(`${response.statusText} : ${errorResponse.error}`, { variant: "error" });
|
enqueueSnackbar(`${response.statusText} : ${errorResponse.error}`, { variant: "error" });
|
||||||
setIsRequesting(false);
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Failed to send request');
|
throw new Error(errorResponse.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getBalances();
|
getBalances();
|
||||||
setIsRequesting(false);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error(error);
|
||||||
throw error;
|
enqueueSnackbar("Error getting tokens from faucet", { variant: "error" });
|
||||||
|
} finally {
|
||||||
|
setIsRequesting(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user