Package com.exonum.binding.core.service
Class ExecutionException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.exonum.binding.core.service.ExecutionException
- All Implemented Interfaces:
java.io.Serializable
public class ExecutionException
extends java.lang.RuntimeException
An error occurred during the execution of a Service method. The execution exception includes
an integer error code, that may be either service-specific or operation-specific;
and an optional description — an exception message. Different error codes allow the clients
of the operation to distinguish between different error conditions.
Exonum translates this exception into an Errors.ExecutionError
type
with error kind equal to Errors.ErrorKind.SERVICE. The execution error copies
the error code and the description from this exception. Exonum saves it into the database in
the registry of call errors.
Note that only the value of the error code affects the blockchain state.
The other attributes of a Java exception — a stack trace, a cause, suppressed exceptions — are not saved in the database. They are used for logging only.
Requesting Execution Errors
An execution error, including the error code and description, can be requested:
- by any Exonum Service, using
Blockchain.getCallRecords(long)
- by an authorized Light Client, using the Exonum endpoints. For example, when the clients requests the transaction information, it will get the execution error, if it occurred. See the Explorer API endpoint documentation for more information.
-
Constructor Summary
Constructors Constructor Description ExecutionException(byte errorCode)
Constructs a new transaction exception with no description.ExecutionException(byte errorCode, java.lang.String description)
Constructs a new transaction exception with the specified description.ExecutionException(byte errorCode, java.lang.String description, java.lang.Throwable cause)
Constructs a new transaction exception with the specified description and cause. -
Method Summary
Modifier and Type Method Description byte
getErrorCode()
Returns the transaction error code.java.lang.String
toString()
Returns a string representation of this error.
-
Constructor Details
-
ExecutionException
public ExecutionException(byte errorCode)Constructs a new transaction exception with no description.- Parameters:
errorCode
- the transaction error code- See Also:
ExecutionPreconditions.checkExecution(boolean, byte)
-
ExecutionException
public ExecutionException(byte errorCode, @Nullable java.lang.String description)Constructs a new transaction exception with the specified description.- Parameters:
errorCode
- the transaction error codedescription
- the error description. The detail description is saved for later retrieval by theThrowable.getMessage()
method.- See Also:
ExecutionPreconditions.checkExecution(boolean, byte, Object)
-
ExecutionException
public ExecutionException(byte errorCode, @Nullable java.lang.String description, @Nullable java.lang.Throwable cause)Constructs a new transaction exception with the specified description and cause.Note that the detail message associated with
cause
is not automatically incorporated in this exception’s detail message.- Parameters:
errorCode
- the transaction error codedescription
- the error description. The detail description is saved for later retrieval by theThrowable.getMessage()
method.cause
- the cause (which is saved for later retrieval by theThrowable.getCause()
method). A null value is permitted, and indicates that the cause is nonexistent or unknown.
-
-
Method Details
-
getErrorCode
public final byte getErrorCode()Returns the transaction error code.- See Also:
Errors.ExecutionError.getCode()
-
toString
public java.lang.String toString()Returns a string representation of this error. Includes the actual class name, the optional description and the error code.- Overrides:
toString
in classjava.lang.Throwable
-