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