emailerrorhandler.java

来自「BEA WebLogic Server 8.1大全 = BEA webLogic」· Java 代码 · 共 58 行

JAVA
58
字号
/*
 * WebLogic Server Unleashed
 */
package com.wlsunleashed.xml.sax;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class EMailErrorHandler implements ErrorHandler {

	/**
	 * Invoked when a "warning" occurs
	 * 
	 * @param warn instance of SAXParseException
	 * @throws Instance of SAXException 
	 */
    public void warning(SAXParseException warn) throws SAXException {
		// We shall print out all warnings and ignore them
		printException(warn);
    }

	/**
	 * Invoked when an "error" occurs
	 * 
	 * @param warn instance of SAXParseException
	 * @throws Instance of SAXException 
	 */
    public void error(SAXParseException error) throws SAXException {
        // print out the error & exit
        printException(error);
        throw new SAXException(error);
    }

	/**
	 * Invoked when a "warning" occurs
	 * 
	 * @param warn instance of SAXParseException
	 * @throws Instance of SAXException 
	 */
    public void fatalError(SAXParseException error) throws SAXException {
		// print out the error & exit
		printException(error);
		throw new SAXException(error);

    }
    
    private void printException(SAXParseException exception) {
    	System.out.println("Error occurred while parsing the XML document");
    	System.out.println("Line # = " + exception.getLineNumber());
    	System.out.println("Column # = " + exception.getColumnNumber());
    	System.out.println(exception.getMessage());
    	System.out.println("Stack Trace");
    	exception.getCause().printStackTrace();
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?