Formats an error code for logs and error messages.

<p>Note that the reason why we don't use enums is because the driver can be extended with
custom codes.
347480
public static String errorCodeString(int errorCode) {
    switch (errorCode) {
      case ProtocolConstants.ErrorCode.SERVER_ERROR:
        return "SERVER_ERROR";
      case ProtocolConstants.ErrorCode.PROTOCOL_ERROR:
        return "PROTOCOL_ERROR";
      case ProtocolConstants.ErrorCode.AUTH_ERROR:
        return "AUTH_ERROR";
      case ProtocolConstants.ErrorCode.UNAVAILABLE:
        return "UNAVAILABLE";
      case ProtocolConstants.ErrorCode.OVERLOADED:
        return "OVERLOADED";
      case ProtocolConstants.ErrorCode.IS_BOOTSTRAPPING:
        return "IS_BOOTSTRAPPING";
      case ProtocolConstants.ErrorCode.TRUNCATE_ERROR:
        return "TRUNCATE_ERROR";
      case ProtocolConstants.ErrorCode.WRITE_TIMEOUT:
        return "WRITE_TIMEOUT";
      case ProtocolConstants.ErrorCode.READ_TIMEOUT:
        return "READ_TIMEOUT";
      case ProtocolConstants.ErrorCode.READ_FAILURE:
        return "READ_FAILURE";
      case ProtocolConstants.ErrorCode.FUNCTION_FAILURE:
        return "FUNCTION_FAILURE";
      case ProtocolConstants.ErrorCode.WRITE_FAILURE:
        return "WRITE_FAILURE";
      case ProtocolConstants.ErrorCode.SYNTAX_ERROR:
        return "SYNTAX_ERROR";
      case ProtocolConstants.ErrorCode.UNAUTHORIZED:
        return "UNAUTHORIZED";
      case ProtocolConstants.ErrorCode.INVALID:
        return "INVALID";
      case ProtocolConstants.ErrorCode.CONFIG_ERROR:
        return "CONFIG_ERROR";
      case ProtocolConstants.ErrorCode.ALREADY_EXISTS:
        return "ALREADY_EXISTS";
      case ProtocolConstants.ErrorCode.UNPREPARED:
        return "UNPREPARED";
      default:
        return "0x" + Integer.toHexString(errorCode);
    }
  }
252532
function format_errors(error_group) {

  /**
   *  Formatted error message, initialize with filename heading.
   */

	var file_errors = error_group.file + '\n\n';

	/**
	 *	Loop through errors.
	 */

	for (var e = 0; e < error_group.errors.length; e++) {

		var error = error_group.errors[e];

		/**
		 *	Fallback for empty values.
		 */

    if (! error.line && error.line !== 0) {
      error.line = '(unknown line)';
    }

    if (! error.character && error.character !== 0) {
      error.character = '(unknown column)';
    }

    if (! error.reason) {
      error.reason = '(unknown error)';
    }

    if (! error.evidence) {
      error.evidence = '(unknown problem)';
    }

    if (! error.code) {
      error.code = '(unknown error code)';
    }

		/**
		 *	Append formatted error to log message.
		 */

		file_errors += '  ['+error.code+'] line ' + error.line + ', column '
      + error.character + ':\n    Error: ' + error.reason
      + '\n    Code block: "' + error.evidence + '"\n\n';

	}

	file_errors += '\n';

	return file_errors;

}
295696
private static String formatCause(Throwable cause) {
    if(cause == null) {
      return "";
    }
    String message = cause.getMessage();
    return "\n" + (message != null ? message : cause.toString());
  }
636027
def format_system_message(errno):
    
    # first some flags used by FormatMessageW
    ALLOCATE_BUFFER = 0x100
    ARGUMENT_ARRAY = 0x2000
    FROM_HMODULE = 0x800
    FROM_STRING = 0x400
    FROM_SYSTEM = 0x1000
    IGNORE_INSERTS = 0x200

    # Let FormatMessageW allocate the buffer (we'll free it below)
    # Also, let it know we want a system error message.
    flags = ALLOCATE_BUFFER | FROM_SYSTEM
    source = None
    message_id = errno
    language_id = 0
    result_buffer = ctypes.wintypes.LPWSTR()
    buffer_size = 0
    arguments = None
    format_bytes = ctypes.windll.kernel32.FormatMessageW(
        flags,
        source,
        message_id,
        language_id,
        ctypes.byref(result_buffer),
        buffer_size,
        arguments,
    )
    # note the following will cause an infinite loop if GetLastError
    #  repeatedly returns an error that cannot be formatted, although
    #  this should not happen.
    handle_nonzero_success(format_bytes)
    message = result_buffer.value
    ctypes.windll.kernel32.LocalFree(result_buffer)
    return message
501258
@JsonIgnore
    public String getErrorMessage() {
        return (params.length == 0) ? exceptionCode.getMessageTemplate() :
                String.format(exceptionCode.getMessageTemplate(), params);
    }
872521
public static String format (Object message, Object... args)
    {
        return new LogBuilder(message, args).toString();
    }
426915
@Nonnull
    public String getMessageWithoutPrefix() {
        BugPattern bugPattern = getBugPattern();
        String pattern, shortPattern;

        pattern = getLongDescription();
        shortPattern = bugPattern.getShortDescription();
        try {
            FindBugsMessageFormat format = new FindBugsMessageFormat(pattern);
            return format.format(annotationList.toArray(new BugAnnotation[annotationList.size()]), getPrimaryClass());
        } catch (RuntimeException e) {
            AnalysisContext.logError("Error generating bug msg ", e);
            return shortPattern + " [Error generating customized description]";
        }
    }
1177677
public String getErrorMessage() {

        StringBuffer result = new StringBuffer(512);

        String reason = m_messages.key(Messages.GUI_REASON_0, new Object[] {});

        if (CmsStringUtil.isNotEmpty(m_errorMessage)) {
            result.append(m_errorMessage);
            result.append("\n").append(reason).append(": ");
        }

        // if a localized message is already set as a parameter, append it.
        result.append(getMessage(m_throwable));
        // recursively append all error reasons to the message
        for (Throwable cause = m_throwable.getCause(); cause != null; cause = cause.getCause()) {
            result.append("\n").append(reason).append(": ");
            result.append(getMessage(cause));
        }
        return result.toString();
    }
722465
private String generateInvalidErrorMessage(Object[] enumValues, String testValue)
    {
        StringBuffer errorMessage = new StringBuffer("Unable to convert value [" + testValue + "].");

        errorMessage.append(" Allowed values are (case insensitive) ");

        StringBuffer valueList = new StringBuffer();

        int index = 1;
        for (Object enumValue : enumValues) {
            if (valueList.length() > 0) {
                if (++index == enumValues.length) {
                    valueList.append(" or ");
                } else {
                    valueList.append(", ");
                }
            }

            valueList.append('"');
            valueList.append(enumValue);
            valueList.append('"');
        }

        errorMessage.append(valueList);
        errorMessage.append('.');

        return errorMessage.toString();
    }
204744
def format(self, record):
        """"""
        record = ColoredRecord(record)
        record.log_color = self.color(self.log_colors, record.levelname)

        # Set secondary log colors
        if self.secondary_log_colors:
            for name, log_colors in self.secondary_log_colors.items():
                color = self.color(log_colors, record.levelname)
                setattr(record, name + '_log_color', color)

        # Format the message
        if sys.version_info > (2, 7):
            message = super(ColoredFormatter, self).format(record)
        else:
            message = logging.Formatter.format(self, record)

        # Add a reset code to the end of the message
        # (if it wasn't explicitly added in format str)
        if self.reset and not message.endswith(escape_codes['reset']):
            message += escape_codes['reset']

        if '|' in message:
            desc, data = message.split("|", 1)
            desc = desc + escape_codes['reset']
            data = escape_codes['green'] + data
            message = desc + '|' + data

        return message
592229
@Override
	public synchronized String format(LogRecord record) {
        // clear string builder content of previous runs
        BUILDER.setLength(0);

        // build log message
        appendDateTime(record);
        appendApplication();
        appendLevel(record);
        appendClass(record);
        appendMessage(record);
        appendThrowable(record);
        appendNewLine();

        return BUILDER.toString();
    }
599327
public void error(String format, Object arg1, Object arg2) {
        formatAndLog(LOG_LEVEL_ERROR, format, arg1, arg2);
    }
808391
public String validationErrors() {

        List<String> errors = new ArrayList<>();
        for (File config : getConfigFiles()) {
            String filename = config.getName();
            try (FileInputStream stream = new FileInputStream(config)) {
                CmsXmlUtils.unmarshalHelper(CmsFileUtil.readFully(stream, false), new CmsXmlEntityResolver(null), true);
            } catch (CmsXmlException e) {
                errors.add(filename + ":" + e.getCause().getMessage());
            } catch (Exception e) {
                errors.add(filename + ":" + e.getMessage());
            }
        }
        if (errors.size() == 0) {
            return null;
        }
        String errString = CmsStringUtil.listAsString(errors, "\n");
        JSONObject obj = new JSONObject();
        try {
            obj.put("err", errString);
        } catch (JSONException e) {

        }
        return obj.toString();
    }
1005497
def handle_error(self, code, message_values=None, raise_error=True):
        
        try:
            if message_values is None:
                message_values = []
            message = self.error_codes.message(code).format(*message_values)
            self.log.error('Error code: {}, {}'.format(code, message))
        except AttributeError:
            self.log.error('Incorrect error code provided ({}).'.format(code))
            raise RuntimeError(1000, 'Generic Failure, see logs for more details.')
        except IndexError:
            self.log.error(
                'Incorrect message values provided for error code {} ({}).'.format(
                    code, message_values
                )
            )
            raise RuntimeError(1000, 'Generic Failure, see logs for more details.')
        if raise_error:
            raise RuntimeError(code, message)
143167
public <Message extends PMessage<Message, Field>, Field extends PField>
    void formatTo(OutputStream out, Message message) {
        IndentedPrintWriter builder = new IndentedPrintWriter(out, indent, newline);
        if (message == null) {
            builder.append(null);
        } else {
            builder.append(message.descriptor().getQualifiedName())
                   .append(space);
            appendMessage(builder, message);
        }
        builder.flush();
    }
876897
@FormatMethod
  private void reportError(@FormatString String message, Object... arguments) {
    errorReporter.reportError(scanner.getPosition(), message, arguments);
  }
1238373
public static void printError(Object caller, Object message)
	{
		
		StringBuilder text = new StringBuilder();

		Class<?> c = callerBuilder(caller, text);

		if(message instanceof Throwable)
			getLog(c).error(text.append(stackTrace((Throwable)message)));
		else
			getLog(c).error(text.append(message));

	}