public static String buildErrorMessage(ErrorType type, String extraMessage, Throwable cause) {

    //Initial message is just the error type message
    StringBuilder message = new StringBuilder(HCatException.class.getName());
    message.append(" : " + type.getErrorCode());
    message.append(" : " + type.getErrorMessage());

    if (extraMessage != null) {
      //Add the extra message value to buffer
      message.append(" : " + extraMessage);
    }

    if (type.appendCauseMessage()) {
      if (cause != null) {
        //Add the cause message to buffer
        message.append(". Cause : " + cause.toString());
      }
    }

    return message.toString();
  }
Builds the error message string. The error type message is appended with the extra message. If appendCause
is true for the error type, then the message of the cause also is added to the message.
@param type the error type
@param extraMessage the extra message string
@param cause the cause for the exception
@return the exception message string
hcatalog/core/src/main/java/org/apache/hive/hcatalog/common/HCatException.java