Class TransactionResult


  • public abstract class TransactionResult
    extends Object
    Returns a result of the transaction execution. This result may be either a success, or an error, if execution has failed. Errors might be either service-defined or unexpected. Service-defined errors consist of an error code and an optional description. Unexpected errors include only a description.
    • Field Detail

      • MAX_USER_DEFINED_ERROR_CODE

        public static final int MAX_USER_DEFINED_ERROR_CODE
        The maximum allowed user-defined transaction error code.
        See Also:
        Constant Field Values
      • SUCCESSFUL_RESULT_STATUS_CODE

        public static final int SUCCESSFUL_RESULT_STATUS_CODE
        The status code of a successfully executed transaction.
        See Also:
        Constant Field Values
      • UNEXPECTED_ERROR_STATUS_CODE

        public static final int UNEXPECTED_ERROR_STATUS_CODE
        The status code of transaction execution corresponding to an unexpected error during transaction execution (some unexpected runtime exception in Java, panic in Rust).
        See Also:
        Constant Field Values
    • Constructor Detail

      • TransactionResult

        public TransactionResult()
    • Method Detail

      • successful

        public static TransactionResult successful()
        Returns a transaction result corresponding to successful execution.
      • error

        public static TransactionResult error​(int errorCode,
                                              @Nullable
                                              String errorDescription)
        Creates a transaction result corresponding to a user-defined exception during transaction execution (or the corresponding Error in Rust services).
        Parameters:
        errorCode - a user-defined error code; must be in range [0; 255]
        errorDescription - an optional error description; may be null, which is considered as no description
      • unexpectedError

        public static TransactionResult unexpectedError​(@Nullable
                                                        String errorDescription)
        Creates a transaction result corresponding to an unexpected error during transaction execution (some unexpected runtime exception in Java, panic in Rust).
        Parameters:
        errorDescription - an optional error description; may be null
      • getType

        public abstract TransactionResult.Type getType()
        Returns the type of this transaction execution result.
        Returns:
        Type.SUCCESS if transaction was successful Type.ERROR if there was a service-defined error during transaction execution Type.UNEXPECTED_ERROR if there was an unexpected error during transaction execution
      • getErrorCode

        public abstract OptionalInt getErrorCode()
        Returns an error code of a transaction if its execution resulted in a service-defined error.
        Returns:
        a transaction error code in case of a service-defined error, or OptionalInt.empty() otherwise
      • getErrorDescription

        public abstract String getErrorDescription()
        Returns the description of a transaction if its execution resulted in an error; or an empty string if there is no description.
      • isSuccessful

        public boolean isSuccessful()
        Returns true if transaction was successful, false otherwise.