Search in sources :

Example 1 with HandledProcessingException

use of com.yahoo.docproc.HandledProcessingException in project vespa by vespa-engine.

the class DocumentProcessingTask method logProcessingFailure.

private static void logProcessingFailure(Processing processing, Exception exception) {
    // LOGGING ONLY:
    String errorMsg = processing + " failed at " + processing.callStack().getLastPopped();
    if (exception != null) {
        if (exception instanceof HandledProcessingException) {
            errorMsg += ". Error message: " + exception.getMessage();
            log.log(Level.WARNING, errorMsg);
            log.log(Level.FINE, "Chained exception:", exception);
        } else {
            log.log(Level.WARNING, errorMsg, exception);
        }
    } else {
        log.log(Level.WARNING, errorMsg);
    }
    // LOGGING OF STACK TRACE:
    if (exception != null) {
        StringWriter backtrace = new StringWriter();
        exception.printStackTrace(new PrintWriter(backtrace));
        log.log(LogLevel.DEBUG, "Failed to process " + processing + ": " + backtrace.toString());
    }
}
Also used : StringWriter(java.io.StringWriter) HandledProcessingException(com.yahoo.docproc.HandledProcessingException) PrintWriter(java.io.PrintWriter)

Aggregations

HandledProcessingException (com.yahoo.docproc.HandledProcessingException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1