Skip to content

Commit 66c70c7

Browse files
committed
[feature] Add location information (source, line-number, and column-number) to XSLT errors
1 parent c2925d7 commit 66c70c7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

exist-core/src/main/java/org/exist/http/servlets/XSLTServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public class XSLTServlet extends HttpServlet {
8989
new XSLTErrorsListener<ServletException>(true, false) {
9090

9191
@Override
92-
protected void raiseError(String error, Exception ex) throws ServletException {
92+
protected void raiseError(final String error, final TransformerException ex) throws ServletException {
9393
throw new ServletException(error, ex);
9494
}
9595
};

exist-core/src/main/java/org/exist/xquery/functions/transform/Transform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
188188
final XSLTErrorsListener<XPathException> errorListener =
189189
new XSLTErrorsListener<XPathException>(stopOnError, stopOnWarn) {
190190
@Override
191-
protected void raiseError(String error, Exception ex) throws XPathException {
191+
protected void raiseError(final String error, final TransformerException ex) throws XPathException {
192192
throw new XPathException(Transform.this, error, ex);
193193
}
194194
};

exist-core/src/main/java/org/exist/xslt/XSLTErrorsListener.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ private enum ErrorType {
4242
private final boolean stopOnWarn;
4343

4444
@Nullable private ErrorType errorType;
45-
@Nullable private Exception exception;
45+
@Nullable private TransformerException exception;
4646

4747
public XSLTErrorsListener(final boolean stopOnError, final boolean stopOnWarn) {
4848
this.stopOnError = stopOnError;
4949
this.stopOnWarn = stopOnWarn;
5050
}
5151

52-
protected abstract void raiseError(String error, Exception ex) throws E;
52+
protected abstract void raiseError(String error, TransformerException ex) throws E;
5353

5454
public void checkForErrors() throws E {
5555
if (errorType == null) {
@@ -59,16 +59,16 @@ public void checkForErrors() throws E {
5959
switch (errorType) {
6060
case WARNING:
6161
if (stopOnWarn) {
62-
raiseError("XSL transform reported warning: " + exception.getMessage(), exception);
62+
raiseError("XSL transform reported warning: " + exception.getMessageAndLocation(), exception);
6363
}
6464
break;
6565
case ERROR:
6666
if (stopOnError) {
67-
raiseError("XSL transform reported error: " + exception.getMessage(), exception);
67+
raiseError("XSL transform reported error: " + exception.getMessageAndLocation(), exception);
6868
}
6969
break;
7070
case FATAL:
71-
raiseError("XSL transform reported error: " + exception.getMessage(), exception);
71+
raiseError("XSL transform reported error: " + exception.getMessageAndLocation(), exception);
7272
}
7373
}
7474

0 commit comments

Comments
 (0)