Example usage for java.util.logging ErrorManager GENERIC_FAILURE

List of usage examples for java.util.logging ErrorManager GENERIC_FAILURE

Introduction

In this page you can find the example usage for java.util.logging ErrorManager GENERIC_FAILURE.

Prototype

int GENERIC_FAILURE

To view the source code for java.util.logging ErrorManager GENERIC_FAILURE.

Click Source Link

Document

GENERIC_FAILURE is used for failure that don't fit into one of the other categories.

Usage

From source file:FileErrorManager.java

/**
 * If the message parameter is a raw email, and passes the store term, then
 * this method will store the email to the file system. If the message
 * parameter is not a raw email then the message is forwarded to the super
 * class. If an email is written to the file system without error, then the
 * original reported error is ignored.//from  w w  w . ja  v a  2  s  . c o m
 *
 * @param msg String raw email or plain error message.
 * @param ex Exception that occurred in the mail handler.
 * @param code int error manager code.
 */
@Override
public void error(String msg, Exception ex, int code) {
    if (isRawEmail(msg)) {
        try {
            storeEmail(msg);
        } catch (final IOException | RuntimeException IOE) {
            next.error(msg, ex, code);
            super.error(emailStore.toString(), IOE, ErrorManager.GENERIC_FAILURE);
        }
    } else {
        next.error(msg, ex, code);
    }
}

From source file:FileErrorManager.java

/**
 * Wraps the given stream as a NewLineOutputStream.
 *
 * @param out the stream to wrap./*  w  w w. ja va2s. c o m*/
 * @return the original or wrapped output stream.
 */
@SuppressWarnings("UseSpecificCatch")
private OutputStream wrap(OutputStream out) {
    assert out != null;
    Class<?> k;
    try {
        k = Class.forName("NewlineOutputStream");
        if (OutputStream.class.isAssignableFrom(k)) {
            Constructor<?> c = k.getConstructor(OutputStream.class);
            return (OutputStream) c.newInstance(out);
        } else {
            super.error("Unable to switch newlines", new ClassNotFoundException(k.getName()),
                    ErrorManager.GENERIC_FAILURE);
        }
    } catch (RuntimeException re) {
        super.error("Unable to switch newlines", re, ErrorManager.GENERIC_FAILURE);
    } catch (Exception ex) {
        super.error("Unable to switch newlines", ex, ErrorManager.GENERIC_FAILURE);
    } catch (LinkageError le) {
        super.error("Unable to switch newlines", new ClassNotFoundException("", le),
                ErrorManager.GENERIC_FAILURE);
    }
    return out;
}