All Products
Search
Document Center

Blockchain as a Service:Error Message

Last Updated:May 21, 2019

After you receive the transaction results, if the transaction is executed incorrectly, you can follow the error code to locate the error.

  • The errorCode field in ErrorCode:MychainBaseResult` shows the reason why the transaction failed.
  • When the request sent is transaction-related, you can obtain a more detailed error code from the return value field of the transaction. For example, the deployment of a smart contract is as follows:
  1. MychainBaseResult<ReplyTransactionReceipt> result = sdk.getContractService()
  2. .deployContract(
  3. DeployContractRequest.build(adminAccount.getIdentity(),
  4. Utils.getIdentityByName(testContractId,env), contractCode, VMTypeEnum.EVM,
  5. contractParameters, BigInteger.ZERO, params));
  6. assertTrue(result.isSuccess());
  7. assertEquals(0, result.getData().getTransactionReceipt().getResult());
  • If result.getData().getTransactionReceipt().getResult() is 0, the transaction is executed successfully. Otherwise, the transaction failed. You can check the value of result and find the reason why the transaction failed in MychainErrorCodeEnum.
  • result.isSuccess() indicates whether the transaction has been sent. If an error occurred when sending the transaction, you can use result.getErrorCode() to obtain the error code.