01: package net.sf.saxon.trans;
02:
03: import net.sf.saxon.expr.XPathContext;
04:
05: import javax.xml.transform.SourceLocator;
06: import javax.xml.transform.TransformerException;
07:
08: /**
09: * Subclass of XPathException used for dynamic errors
10: */
11:
12: public class DynamicError extends XPathException {
13:
14: transient XPathContext context;
15:
16: // declared transient because a compiled stylesheet might contain a "deferred action" dynamic error
17: // and the EarlyEvaluationContext links back to the source stylesheet.
18:
19: public DynamicError(String message) {
20: super (message);
21: }
22:
23: public DynamicError(Throwable err) {
24: super (err);
25: }
26:
27: public DynamicError(String message, Throwable err) {
28: super (message, err);
29: }
30:
31: public DynamicError(String message, SourceLocator loc) {
32: super (message, loc);
33: }
34:
35: public DynamicError(String message, SourceLocator loc, Throwable err) {
36: super (message, loc, err);
37: }
38:
39: public void setXPathContext(XPathContext context) {
40: this .context = context;
41: }
42:
43: public XPathContext getXPathContext() {
44: return context;
45: }
46:
47: public static DynamicError makeDynamicError(TransformerException err) {
48: if (err instanceof DynamicError) {
49: return (DynamicError) err;
50: } else if (err instanceof XPathException) {
51: DynamicError de = new DynamicError(err);
52: de.setErrorCode(((XPathException) err)
53: .getErrorCodeLocalPart());
54: de.setLocator(err.getLocator());
55: return de;
56: } else {
57: return new DynamicError(err);
58: }
59: }
60: }
|