static void convertToSAXException(XNIException e) throws SAXException { Exception ex = e.getException(); if (ex == null) { throw new SAXException(e.getMessage()); } if (ex instanceof SAXException) { throw (SAXException) ex; } throw new SAXException(ex); }
/** * Error. * * @param domain * the domain * @param key * the key * @param exception * the exception * @throws XNIException * the xNI exception {@inheritDoc} * @see org.apache.xerces.xni.parser.XMLErrorHandler#error(java.lang.String, java.lang.String, * org.apache.xerces.xni.parser.XMLParseException) */ @Override public void error(final String domain, final String key, final XMLParseException exception) throws XNIException { throw new XNIException("domain=" + domain + ", key=" + key + ", exception=" + exception, exception); }
/** Returns the cause of this <code>XNIException</code>. */ public Throwable getCause() { return getException(); } // getCause():Throwable
e.printStackTrace(); Exception ex = e.getException(); if (ex == null) { throw new SAXException(e.getMessage());
new Object[] { href, ex.getMessage()}); return false; throw new XNIException(e); throw new XNIException(e);
/** * Converts the {@link XNIException} received from a downstream * component to a {@link SAXException}. */ private SAXException toSAXException( XNIException xe ) { Exception e = xe.getException(); if( e==null ) e = xe; if( e instanceof SAXException ) return (SAXException)e; return new SAXException(e); }
/** * Fatal error. * * @param domain * the domain * @param key * the key * @param exception * the exception * @throws XNIException * the xNI exception {@inheritDoc} * @see org.apache.xerces.xni.parser.XMLErrorHandler#fatalError(java.lang.String, * java.lang.String, org.apache.xerces.xni.parser.XMLParseException) */ @Override public void fatalError(final String domain, final String key, final XMLParseException exception) throws XNIException { throw new XNIException("domain=" + domain + ", key=" + key + ", exception=" + exception, exception); }
/** * Reconstructs {@link SAXException} from XNIException. */ public static SAXException toSAXException(XNIException e) { if(e instanceof XMLParseException) return toSAXParseException((XMLParseException)e); if( e.getException() instanceof SAXException ) return (SAXException)e.getException(); return new SAXException(e.getMessage(),e.getException()); }
/** * Extract nested exception within an XNIException (Nekohtml uses reflection and generated * exceptions are wrapped many times within XNIException and InvocationTargetException) * * @param e the original XNIException * @return the cause exception */ static Throwable extractNestedException(final Throwable e) { Throwable originalException = e; Throwable cause = ((XNIException) e).getException(); while (cause != null) { originalException = cause; if (cause instanceof XNIException) { cause = ((XNIException) cause).getException(); } else if (cause instanceof InvocationTargetException) { cause = cause.getCause(); } else { cause = null; } } return originalException; }
public void characters(XMLString text, Augmentations augs) throws XNIException { try { fContentHandler.characters(text.ch,text.offset,text.length); } catch (SAXException e) { throw new XNIException(e); } }
static SAXException toSAXException(XNIException e) { if (e instanceof XMLParseException) { XMLParseException pe = (XMLParseException)e; return new SAXParseException(pe.getMessage(), pe.getPublicId(), pe.getExpandedSystemId(), pe.getLineNumber(), pe.getColumnNumber(), pe.getException()); } Exception nested = e.getException(); if (nested == null) return new SAXException(e.getMessage()); if (nested instanceof SAXException) return (SAXException)nested; if (nested instanceof RuntimeException) throw (RuntimeException)nested; return new SAXException(nested); } }
/** * Extract nested exception within an XNIException (Nekohtml uses reflection and generated * exceptions are wrapped many times within XNIException and InvocationTargetException) * * @param e the original XNIException * @return the cause exception */ static Throwable extractNestedException(final Throwable e) { Throwable originalException = e; Throwable cause = ((XNIException) e).getException(); while (cause != null) { originalException = cause; if (cause instanceof XNIException) { cause = ((XNIException) cause).getException(); } else if (cause instanceof InvocationTargetException) { cause = cause.getCause(); } else { cause = null; } } return originalException; }
public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException { if (fContentHandler != null) { try { fContentHandler.ignorableWhitespace(text.ch, text.offset, text.length); } catch (SAXException e) { throw new XNIException(e); } } }
static SAXException toSAXException(XNIException e) { if (e instanceof XMLParseException) { XMLParseException pe = (XMLParseException)e; return new SAXParseException(pe.getMessage(), pe.getPublicId(), pe.getExpandedSystemId(), pe.getLineNumber(), pe.getColumnNumber(), pe.getException()); } Exception nested = e.getException(); if (nested == null) return new SAXException(e.getMessage()); if (nested instanceof SAXException) return (SAXException)nested; if (nested instanceof RuntimeException) throw (RuntimeException)nested; return new SAXException(nested); } }
/** * Extract nested exception within an XNIException (Nekohtml uses reflection and generated * exceptions are wrapped many times within XNIException and InvocationTargetException) * * @param e the original XNIException * @return the cause exception */ static Throwable extractNestedException(final Throwable e) { Throwable originalException = e; Throwable cause = ((XNIException) e).getException(); while (cause != null) { originalException = cause; if (cause instanceof XNIException) { cause = ((XNIException) cause).getException(); } else if (cause instanceof InvocationTargetException) { cause = cause.getCause(); } else { cause = null; } } return originalException; }