Show error snackbar in catch block
This commit is contained in:
parent
57e2c0c628
commit
0dda671e1f
@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from 'jwt-decode';
|
||||||
import { ethers } from 'ethers';
|
import { ethers } from 'ethers';
|
||||||
|
|
||||||
import { Box, colors, Typography } from '@mui/material';
|
import { Box, colors, Typography } from '@mui/material';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import { enqueueSnackbar } from 'notistack';
|
import { enqueueSnackbar } from 'notistack';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { MsgCreateValidator } from 'cosmjs-types/cosmos/staking/v1beta1/tx';
|
||||||
|
|
||||||
import { Box, Link, MenuItem, Select, TextField, Typography } from '@mui/material';
|
import { Box, Link, MenuItem, Select, TextField, Typography } from '@mui/material';
|
||||||
import { MsgCreateValidator } from 'cosmjs-types/cosmos/staking/v1beta1/tx';
|
|
||||||
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
||||||
import { LoadingButton } from '@mui/lab';
|
import { LoadingButton } from '@mui/lab';
|
||||||
import { EncodeObject, encodePubkey } from '@cosmjs/proto-signing';
|
import { EncodeObject, encodePubkey } from '@cosmjs/proto-signing';
|
||||||
@ -43,11 +43,11 @@ const Validator = () => {
|
|||||||
if (fetchedParticipant) {
|
if (fetchedParticipant) {
|
||||||
setParticipant(fetchedParticipant);
|
setParticipant(fetchedParticipant);
|
||||||
} else {
|
} else {
|
||||||
enqueueSnackbar("Participant not found", { variant: "error" });
|
throw new Error("Participant not found");
|
||||||
setParticipant(null);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching participant", error);
|
console.error("Error fetching participant", error);
|
||||||
|
enqueueSnackbar("Error in fetching participant", { variant: "error" });
|
||||||
setParticipant(null);
|
setParticipant(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -118,7 +118,7 @@ const Validator = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.code !== 0) {
|
if (response.code !== 0) {
|
||||||
enqueueSnackbar("Transaction not sent", { variant: "error" });
|
throw new Error("Transaction not sent");
|
||||||
} else {
|
} else {
|
||||||
navigate("/validator-success", { state: { validatorAddress: msgCreateValidator.validatorAddress, } });
|
navigate("/validator-success", { state: { validatorAddress: msgCreateValidator.validatorAddress, } });
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
import { Box, Link, Typography } from '@mui/material';
|
import { Box, Link, Typography } from '@mui/material';
|
||||||
import { useLocation } from 'react-router-dom';
|
|
||||||
|
|
||||||
const ValidatorSuccess = () => {
|
const ValidatorSuccess = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
Loading…
Reference in New Issue
Block a user