fix: show error message correctly (#2705)
This commit is contained in:
parent
e883ef5c5e
commit
01e7b8caee
@ -5,12 +5,14 @@ interface StakeFailureProps {
|
||||
nodeName: string;
|
||||
isDialogVisible: boolean;
|
||||
toggleDialog: () => void;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
export const StakeFailure = ({
|
||||
nodeName,
|
||||
isDialogVisible,
|
||||
toggleDialog,
|
||||
error,
|
||||
}: StakeFailureProps) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
@ -20,11 +22,15 @@ export const StakeFailure = ({
|
||||
open={isDialogVisible}
|
||||
onChange={toggleDialog}
|
||||
>
|
||||
<p>
|
||||
{t('stakeFailed', {
|
||||
node: nodeName,
|
||||
})}
|
||||
</p>
|
||||
{error ? (
|
||||
<p>{error.message}</p>
|
||||
) : (
|
||||
<p>
|
||||
{t('stakeFailed', {
|
||||
node: nodeName,
|
||||
})}
|
||||
</p>
|
||||
)}
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
@ -13,6 +13,7 @@ interface StakeFormTxStatusesProps {
|
||||
removeType: RemoveType;
|
||||
isDialogVisible: boolean;
|
||||
toggleDialog: () => void;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
export const StakingFormTxStatuses = ({
|
||||
@ -23,6 +24,7 @@ export const StakingFormTxStatuses = ({
|
||||
removeType,
|
||||
isDialogVisible,
|
||||
toggleDialog,
|
||||
error,
|
||||
}: StakeFormTxStatusesProps) => {
|
||||
switch (formState) {
|
||||
case FormState.Requested:
|
||||
@ -59,6 +61,7 @@ export const StakingFormTxStatuses = ({
|
||||
nodeName={nodeName}
|
||||
isDialogVisible={isDialogVisible}
|
||||
toggleDialog={toggleDialog}
|
||||
error={error}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
|
@ -70,6 +70,7 @@ export const StakingForm = ({
|
||||
const { appState } = useAppState();
|
||||
const { sendTx } = useVegaWallet();
|
||||
const [formState, setFormState] = React.useState(FormState.Default);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
const [isDialogVisible, setIsDialogVisible] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const [action, setAction] = React.useState<StakeAction>(
|
||||
@ -135,12 +136,15 @@ export const StakingForm = ({
|
||||
|
||||
// await success via poll
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
setError(err);
|
||||
}
|
||||
setFormState(FormState.Failure);
|
||||
Sentry.captureException(err);
|
||||
}
|
||||
}
|
||||
|
||||
const [delegationSearch, { data, error }] = usePartyDelegationsLazyQuery({
|
||||
const [delegationSearch, { data }] = usePartyDelegationsLazyQuery({
|
||||
variables: {
|
||||
partyId: pubKey,
|
||||
},
|
||||
@ -170,10 +174,6 @@ export const StakingForm = ({
|
||||
clearInterval(interval);
|
||||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@ -306,6 +306,7 @@ export const StakingForm = ({
|
||||
removeType={removeType}
|
||||
isDialogVisible={isDialogVisible}
|
||||
toggleDialog={toggleDialog}
|
||||
error={error}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user