Package org.hyperledger.fabric.shim
Class ChaincodeException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.hyperledger.fabric.shim.ChaincodeException
-
- All Implemented Interfaces:
java.io.Serializable
public class ChaincodeException extends java.lang.RuntimeException
Contracts should useChaincodeException
to indicate when an error occurs in Smart Contract logic.When a
ChaincodeException
is thrown an error response will be returned from the chaincode container containing the exception message and payload, if specified.ChaincodeException
may be extended to provide application specific error information. Subclasses should ensure thatgetPayload()
returns a serialized representation of the error in a suitable format for client applications to process.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ChaincodeException()
Constructs a newChaincodeException
with no detail message.ChaincodeException(java.lang.String message)
Constructs a newChaincodeException
with the specified detail message.ChaincodeException(java.lang.String message, byte[] payload)
Constructs a newChaincodeException
with the specified detail message and response payload.ChaincodeException(java.lang.String message, byte[] payload, java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified detail message, response payload and cause.ChaincodeException(java.lang.String message, java.lang.String payload)
Constructs a newChaincodeException
with the specified detail message and response payload.ChaincodeException(java.lang.String message, java.lang.String payload, java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified detail message, response payload and cause.ChaincodeException(java.lang.String message, java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified detail message and cause.ChaincodeException(java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified cause.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getPayload()
Returns the response payload ornull
if there is no response.
-
-
-
Constructor Detail
-
ChaincodeException
public ChaincodeException()
Constructs a newChaincodeException
with no detail message.
-
ChaincodeException
public ChaincodeException(java.lang.String message)
Constructs a newChaincodeException
with the specified detail message.- Parameters:
message
- the detail message.
-
ChaincodeException
public ChaincodeException(java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified cause.- Parameters:
cause
- the cause.
-
ChaincodeException
public ChaincodeException(java.lang.String message, java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified detail message and cause.- Parameters:
message
- the detail message.cause
- the cause.
-
ChaincodeException
public ChaincodeException(java.lang.String message, byte[] payload)
Constructs a newChaincodeException
with the specified detail message and response payload.- Parameters:
message
- the detail message.payload
- the response payload.
-
ChaincodeException
public ChaincodeException(java.lang.String message, byte[] payload, java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified detail message, response payload and cause.- Parameters:
message
- the detail message.payload
- the response payload.cause
- the cause.
-
ChaincodeException
public ChaincodeException(java.lang.String message, java.lang.String payload)
Constructs a newChaincodeException
with the specified detail message and response payload.- Parameters:
message
- the detail message.payload
- the response payload.
-
ChaincodeException
public ChaincodeException(java.lang.String message, java.lang.String payload, java.lang.Throwable cause)
Constructs a newChaincodeException
with the specified detail message, response payload and cause.- Parameters:
message
- the detail message.payload
- the response payload.cause
- the cause.
-
-
Method Detail
-
getPayload
public byte[] getPayload()
Returns the response payload ornull
if there is no response.The payload should represent the chaincode error in a way that client applications written in different programming languages can interpret. For example it could include a domain specific error code, in addition to any state information which would allow client applications to respond appropriately.
- Returns:
- the response payload or
null
if there is no response.
-
-