Search in sources :

Example 1 with ErrorStringBuilder

use of org.apache.derby.shared.common.error.ErrorStringBuilder in project derby by apache.

the class Util method logError.

private static void logError(String errorMessage, Throwable t) {
    HeaderPrintWriter errorStream = Monitor.getStream();
    if (errorStream == null) {
        t.printStackTrace();
        return;
    }
    ErrorStringBuilder errorStringBuilder = new ErrorStringBuilder(errorStream.getHeader());
    errorStringBuilder.append(errorMessage);
    errorStringBuilder.stackTrace(t);
    errorStream.print(errorStringBuilder.get().toString());
    errorStream.flush();
    errorStringBuilder.reset();
}
Also used : ErrorStringBuilder(org.apache.derby.shared.common.error.ErrorStringBuilder) HeaderPrintWriter(org.apache.derby.shared.common.stream.HeaderPrintWriter)

Example 2 with ErrorStringBuilder

use of org.apache.derby.shared.common.error.ErrorStringBuilder in project derby by apache.

the class LogToFile method printErrorStack.

/**
 * print stack trace from the Throwable including
 * its nested exceptions
 * @param t trace starts from this error
 */
private void printErrorStack(Throwable t) {
    ErrorStringBuilder esb = new ErrorStringBuilder(Monitor.getStream().getHeader());
    esb.stackTrace(t);
    Monitor.logMessage(esb.get().toString());
    esb.reset();
}
Also used : ErrorStringBuilder(org.apache.derby.shared.common.error.ErrorStringBuilder)

Example 3 with ErrorStringBuilder

use of org.apache.derby.shared.common.error.ErrorStringBuilder in project derby by apache.

the class ReplicationLogger method logError.

/**
 * Print error message and the stack trace of the throwable to the
 * log (usually derby.log) provided that verbose
 * is true. If verbose is false, nothing is
 * logged.
 *
 * @param msgId The error message id
 * @param t Error trace starts from this error
 */
public void logError(String msgId, Throwable t) {
    if (verbose) {
        Monitor.logTextMessage(MessageId.REPLICATION_ERROR_BEGIN, new Date());
        if (msgId != null) {
            Monitor.logTextMessage(msgId, dbname);
        }
        if (t != null) {
            ErrorStringBuilder esb = new ErrorStringBuilder(Monitor.getStream().getHeader());
            esb.stackTrace(t);
            Monitor.logMessage(esb.get().toString());
            esb.reset();
        }
        Monitor.logTextMessage(MessageId.REPLICATION_ERROR_END);
    }
}
Also used : ErrorStringBuilder(org.apache.derby.shared.common.error.ErrorStringBuilder) Date(java.util.Date)

Example 4 with ErrorStringBuilder

use of org.apache.derby.shared.common.error.ErrorStringBuilder in project derby by apache.

the class BaseMonitor method reportException.

protected void reportException(Throwable t) {
    PrintWriterGetHeader pwgh = null;
    if (systemStreams != null)
        pwgh = systemStreams.stream().getHeader();
    ErrorStringBuilder esb = new ErrorStringBuilder(pwgh);
    esb.appendln(t.getMessage());
    esb.stackTrace(t);
    report(esb.get().toString());
}
Also used : ErrorStringBuilder(org.apache.derby.shared.common.error.ErrorStringBuilder) PrintWriterGetHeader(org.apache.derby.shared.common.stream.PrintWriterGetHeader)

Aggregations

ErrorStringBuilder (org.apache.derby.shared.common.error.ErrorStringBuilder)4 Date (java.util.Date)1 HeaderPrintWriter (org.apache.derby.shared.common.stream.HeaderPrintWriter)1 PrintWriterGetHeader (org.apache.derby.shared.common.stream.PrintWriterGetHeader)1