Class TransactionResult


  • public abstract class TransactionResult
    extends java.lang.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.
    See Also:
    TransactionExecutionException
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TransactionResult.Type
      A type of transaction execution result.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_USER_DEFINED_ERROR_CODE
      The maximum allowed user-defined transaction error code.
      static int SUCCESSFUL_RESULT_STATUS_CODE
      The status code of a successfully executed transaction.
      static 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).
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static TransactionResult error​(int errorCode, java.lang.String errorDescription)
      Creates a transaction result corresponding to a user-defined exception during transaction execution (or the corresponding Error in Rust services).
      abstract java.util.OptionalInt getErrorCode()
      Returns an error code of a transaction if its execution resulted in a service-defined error.
      abstract java.lang.String getErrorDescription()
      Returns the description of a transaction if its execution resulted in an error; or an empty string if there is no description.
      abstract TransactionResult.Type getType()
      Returns the type of this transaction execution result.
      boolean isSuccessful()
      Returns true if transaction was successful, false otherwise.
      static TransactionResult successful()
      Returns a transaction result corresponding to successful execution.
      static com.google.gson.TypeAdapter<TransactionResult> typeAdapter​(com.google.gson.Gson gson)
      Provides a Gson type adapter for this class.
      static TransactionResult unexpectedError​(java.lang.String errorDescription)
      Creates a transaction result corresponding to an unexpected error during transaction execution (some unexpected runtime exception in Java, panic in Rust).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
                                              java.lang.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
                                                        java.lang.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 java.util.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 java.lang.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.