Skip to content

Commit

Permalink
Fix bad error message handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
averytt committed Mar 4, 2021
1 parent 9d3796a commit e6cf02e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/components/Warning.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
.Warning{
background-color: red;
padding: 6px 12px;
display: block;
margin-left: auto;
margin-right: auto;
border-radius: 6px;
background-color: rgba(255, 48, 86, 0.30);
color:white;
color:#FF3056;
font-size: 14px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Warning = ({ message, learnMoreHref, style, className }) => {
rel='noopener noreferrer'
>Learn more</a>
</div>
)
);
};

export default Warning;
14 changes: 8 additions & 6 deletions src/state/actions/Transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import ThetaJS from "../../libs/thetajs.esm";
import ContractModes from "../../constants/ContractModes";
import Router from "../../services/Router";

const DefaultTransactionErrorMessage = "An error occurred while sending your transaction. Please wait and try again.";

export function fetchThetaTransactions() {
let address = Wallet.getWalletAddress();

Expand Down Expand Up @@ -73,7 +75,8 @@ export async function createSendTransactionAsync(dispatch, network, txData, pass
dispatch(hideModals());
},
onError: function (dispatch, response) {
Alerts.showError(response.body.message);
const errorMessage = _.get(response, ['body', 'message'], DefaultTransactionErrorMessage)
Alerts.showError(errorMessage);
}
};

Expand Down Expand Up @@ -115,9 +118,6 @@ export async function createDepositStakeTransactionAsync(dispatch, network, txDa
txData: txData,
};

console.log("createDepositStakeTransactionAsync :: txData == ");
console.log(txData);

//The decryption can take some time, so start the event early
dispatch({
type: CREATE_DEPOSIT_STAKE_TRANSACTION_START,
Expand All @@ -144,7 +144,8 @@ export async function createDepositStakeTransactionAsync(dispatch, network, txDa
dispatch(hideModals());
},
onError: function (dispatch, response) {
Alerts.showError(response.body.message);
const errorMessage = _.get(response, ['body', 'message'], DefaultTransactionErrorMessage)
Alerts.showError(errorMessage);
}
};

Expand Down Expand Up @@ -211,7 +212,8 @@ export async function createWithdrawStakeTransactionAsync(dispatch, network, txD
dispatch(hideModals());
},
onError: function (dispatch, response) {
Alerts.showError(response.body.message);
const errorMessage = _.get(response, ['body', 'message'], DefaultTransactionErrorMessage)
Alerts.showError(errorMessage);
}
};

Expand Down

0 comments on commit e6cf02e

Please sign in to comment.