protected void setSaxonConfig(Input saxonConfig) { needsCheck = true; if ((this.saxonConfig != null) && (saxonConfig != null)) { throw new XProcException("Multiple saxonConfig are not supported."); } this.saxonConfig = saxonConfig; }
/** * @param offset Make the locator of this error start "offset" number of frames from * the point where this method is called (a positive number results in * less frames in the locator). */ public static XProcException javaError(Throwable throwable, int offset) { StackTraceElement[] base = new RuntimeException().getStackTrace(); return javaError(throwable, offset, base, 1); }
private void dynamicError(int errno) { String msg = null; if (stepName != null) { msg = "Reading " + portName + " on " + stepName; } throw XProcException.dynamicError(errno, (String) msg); } }
public SourceLocator[] getLocator() { return getLocator(getStep(), getNode()); }
public XProcException rebaseOnto(SourceLocator[] base) { return rebaseOnto(getStep(), base); }
public XProcException rebaseOnto(Step step) { return rebaseOnto(step, getLocator(step)); }
private String checkNCName(String name) { if (name != null) { try { TypeUtils.checkType(runtime, name, XProcConstants.xs_NCName,null); } catch (XProcException xe) { throw new XProcException("Invalid name: \"" + name + "\". Step and port names must be NCNames.", xe.getCause()); } } return name; }
throw XProcException.dynamicError(6, step.getNode(), "No stylesheet provided."); throw XProcException.stepError(39); message = catchMessages.getTerminatingMessage().toString(); final SourceLocator[] frames = XProcException.getLocator((TransformerException)e); Throwable cause = e.getCause(); if (cause != null) { if (cause instanceof XProcException) throw ((XProcException)cause).rebaseOnto(frames); else throw new XProcException(message, XProcException.javaError(cause, 0)) { @Override public SourceLocator[] getLocator() { return frames; }}; } else throw XProcException.javaError(sae, 0); S9apiUtils.serialize(runtime, xformed, serializer); } catch (SaxonApiException e2) { throw new XProcException(e2); resultPipe.write(tree.getResult()); } else { throw new XProcException(step.getStep(), "p:xslt returned non-XML result", e.getCause());
public void run() throws SaxonApiException { super.run(); try { XdmNode doc = runtime.getConfigurer().getXMLCalabashConfigurer().loadDocument(this); result.write(doc); } catch (XProcException e) { logger.debug(e.getMessage(), e); if (err_XD0011.equals(e.getErrorCode())) { RuntimeValue href = getOption(_href); String baseURI = href.getBaseURI().toASCIIString(); boolean validate = getOption(_dtd_validate, false); throw XProcException.stepError(11, "Could not load " + href.getString() + " (" + baseURI + ") dtd-validate=" + validate); } throw e; } catch (Exception e) { throw new XProcException(e); } } }
if (XProcConstants.dynamicError(11).equals(xe.getErrorCode())) { throw XProcException.staticError(52, node, xe.getCause(), "Cannot import: " + importURI.toASCIIString()); } else { throw xe; throw new XProcException(e);
loc = err.getLocator()[0]; if (err.getErrorCode() != null) { QName n = err.getErrorCode(); qCode = new StructuredQName(n.getPrefix(),n.getNamespaceURI(),n.getLocalName()); if (err.getStep() != null) { message = message + err.getStep() + ":";
private XProcException rebaseOnto(final Step step, SourceLocator[] base) { final QName error = this.getErrorCode(); final String message = this.getMessage(); final XdmNode node = this.getNode(); final SourceLocator[] location; { SourceLocator[] l = this.getLocator(); int originalLength = l.length; if (l.length == 1 && l[0] instanceof XMLLocation && getStep() == null && getNode() == null && base.length > 0) originalLength = 0; location = new SourceLocator[base.length + originalLength]; Throwable c = this.getCause(); if (c != null && c instanceof XProcException) cause = ((XProcException)c).rebaseOnto(base); else cause = c;
xpipeline.run(); } catch (XProcException e) { logger.debug(e.getMessage(), e); throw e; } catch (Throwable e) { logger.debug(e.getMessage(), e); throw new XProcException(e);
throw new XProcException(sae); parse(cnode); } catch (XProcException xe) { if (XProcConstants.dynamicError(11).equals(xe.getErrorCode())) { parse(cnode); } catch (XProcException xe) { if (XProcConstants.dynamicError(11).equals(xe.getErrorCode())) { throw new XProcException("Invalid Saxon processor specified in com.xmlcalabash.saxon-processor property."); logOpt = LogOptions.DIRECTORY; } else { throw new XProcException("Invalid log-style specified in com.xmlcalabash.log-style property");
throw XProcException.dynamicError(6, step.getNode(), "No stylesheet provided."); throw XProcException.stepError(39); S9apiUtils.serialize(runtime, xformed, serializer); } catch (SaxonApiException e2) { throw new XProcException(e2); resultPipe.write(tree.getResult()); } else { throw new XProcException(step.getStep(), "p:xslt returned non-XML result", e.getCause());
userArgs = new ParseArgs().parse(args); } catch (XProcException xe) { System.err.println(xe.getMessage()); usage(); } catch (XProcException err) { exitStatus = 1; if (err.getErrorCode() != null) { logger.error(errorMessage(err.getErrorCode())); } else { logger.error(err.getMessage()); Throwable cause = err.getCause(); while (cause != null && cause instanceof XProcException) { cause = cause.getCause(); logger.debug(err.getMessage(), err); } catch (Exception err) { exitStatus = 1;
protected XProcException handleException(Throwable e) { XProcException xe = (e instanceof XProcException) ? (XProcException)e : XProcException.javaError(e, 1, new RuntimeException().getStackTrace(), 1); if (getRootStep(xe.getStep()) != getRootStep(getStep())) xe = xe.rebaseOnto(getStep()); return xe; }
public String getCode() { if (e.getErrorCode() != null) return e.getErrorCode().toString(); else return null; }
QName code = xxx.getErrorCode(); message = xxx.getMessage(); Throwable underlying = xe.getCause(); if (underlying != null) {
QName code = xxx.getErrorCode(); if (code != null) { qCode = new StructuredQName(code.getPrefix(), code.getNamespaceURI(), code.getLocalName()); treeWriter.addStartElement(px_location); treeWriter.startContent(); for (SourceLocator l : xxx.getLocator()) { treeWriter.addStartElement(px_file); treeWriter.addAttribute(_href, l.getSystemId());