code: public static ByteBuf serializeRequestFailure(
  			final ByteBufAllocator alloc,
  			final long requestId,
  			final Throwable cause) throws IOException {
  
  		final ByteBuf buf = alloc.ioBuffer();
  
  		// Frame length is set at the end
  		buf.writeInt(0);
  		writeHeader(buf, MessageType.REQUEST_FAILURE);
  		buf.writeLong(requestId);
  
  		try (ByteBufOutputStream bbos = new ByteBufOutputStream(buf);
  				ObjectOutput out = new ObjectOutputStream(bbos)) {
  			out.writeObject(cause);
  		}
  
  		// Set frame length
  		int frameLength = buf.readableBytes() - Integer.BYTES;
  		buf.setInt(0, frameLength);
  		return buf;
  	}
docs: Serializes the exception containing the failure message sent to the
  {@link org.apache.flink.queryablestate.network.Client} in case of
  protocol related errors.
  
  @param alloc			The {@link ByteBufAllocator} used to allocate the buffer to serialize the message into.
  @param requestId		The id of the request to which the message refers to.
  @param cause			The exception thrown at the server.
  @return A {@link ByteBuf} containing the serialized message.