Class ChaincodeException

  • All Implemented Interfaces:
    java.io.Serializable

    public class ChaincodeException
    extends java.lang.RuntimeException
    Contracts should use ChaincodeException 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 that getPayload() 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 new ChaincodeException with no detail message.
      ChaincodeException​(java.lang.String message)
      Constructs a new ChaincodeException with the specified detail message.
      ChaincodeException​(java.lang.String message, byte[] payload)
      Constructs a new ChaincodeException with the specified detail message and response payload.
      ChaincodeException​(java.lang.String message, byte[] payload, java.lang.Throwable cause)
      Constructs a new ChaincodeException with the specified detail message, response payload and cause.
      ChaincodeException​(java.lang.String message, java.lang.String payload)
      Constructs a new ChaincodeException with the specified detail message and response payload.
      ChaincodeException​(java.lang.String message, java.lang.String payload, java.lang.Throwable cause)
      Constructs a new ChaincodeException with the specified detail message, response payload and cause.
      ChaincodeException​(java.lang.String message, java.lang.Throwable cause)
      Constructs a new ChaincodeException with the specified detail message and cause.
      ChaincodeException​(java.lang.Throwable cause)
      Constructs a new ChaincodeException with the specified cause.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getPayload()
      Returns the response payload or null if there is no response.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ChaincodeException

        public ChaincodeException()
        Constructs a new ChaincodeException with no detail message.
      • ChaincodeException

        public ChaincodeException​(java.lang.String message)
        Constructs a new ChaincodeException with the specified detail message.
        Parameters:
        message - the detail message.
      • ChaincodeException

        public ChaincodeException​(java.lang.Throwable cause)
        Constructs a new ChaincodeException with the specified cause.
        Parameters:
        cause - the cause.
      • ChaincodeException

        public ChaincodeException​(java.lang.String message,
                                  java.lang.Throwable cause)
        Constructs a new ChaincodeException 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 new ChaincodeException 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 new ChaincodeException 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 new ChaincodeException 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 new ChaincodeException 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 or null 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.