001 package railo.runtime.text.xml; 002 003 import org.xml.sax.ErrorHandler; 004 import org.xml.sax.SAXException; 005 import org.xml.sax.SAXParseException; 006 007 008 public class ThrowingErrorHandler implements ErrorHandler { 009 010 private boolean throwFatalError; 011 private boolean throwError; 012 private boolean throwWarning; 013 014 public ThrowingErrorHandler(boolean throwFatalError,boolean throwError,boolean throwWarning) { 015 this.throwFatalError=throwFatalError; 016 this.throwError=throwError; 017 this.throwWarning=throwWarning; 018 } 019 020 @Override 021 public void error(SAXParseException e) throws SAXException { 022 if(throwError)throw new SAXException(e); 023 } 024 025 @Override 026 public void fatalError(SAXParseException e) throws SAXException { 027 if(throwFatalError)throw new SAXException(e); 028 } 029 030 @Override 031 public void warning(SAXParseException e) throws SAXException { 032 if(throwWarning)throw new SAXException(e); 033 } 034 035 }