Project

Profile

Help

Bug #5781

closed

If the stylesheet is not well-formed, compile_stylesheet silently ignores the error

Added by Norm Tovey-Walsh about 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Start date:
2022-12-22
Due date:
% Done:

100%

Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
12.0
Fixed in version:
12.1
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:

Description

When I was putting together the test page for the 11.99 pre-release, I had this method call:

 xexec = xslt.compile_stylesheet(stylesheet_file="doc2html.xsl")

I was unaware that I'd introduced a markup error in the stylesheet and compile_stylesheet() simply returned None without any error message. It was only later when I attempted to parse the stylesheet as XML that the error was reported.


Related issues

Related to SaxonC - Bug #5851: Exception found in XdmFunctionItem.call Message=ClosedO'Neil Delpratt2023-01-23

Actions
Actions #1

Updated by Norm Tovey-Walsh about 2 years ago

  • Private changed from Yes to No
Actions #2

Updated by O'Neil Delpratt about 2 years ago

Due to historic reasons to do with JNI exception handling in SaxonC 11 "Exceptions and errors are captured and maintained silently in SaxonC, but can be accessed" this is via the @getErrorMessage()@ method. See the SaxonC 11 documentation section on debugging: https://www.saxonica.com/saxon-c/documentation11/index.html#!technical/debugging

Therefore I have modified your code with some error handling:

xexec = xslt.compile_stylesheet(stylesheet_file="doc2html.xsl")
if xexec is None and xslt.exception_occurred:
    print(xslt.error_message)
    .......

As a first cut in SaxonC 12 we have maintained the same approach. However for SaxonC 12 there is no reason to stick to this approach of handing exceptions since we have a new and better internal design to manage exceptions and report them from Java to C++, this is because in with Graalvm we are no longer using JNI.

I hope the above workaround will work for you, while I will later look at making a widespread change to how we report exceptions. Ideally we should just get the error message reported by the exception handler from Java and throw it the exception in C++, python and PHP.

Actions #3

Updated by O'Neil Delpratt almost 2 years ago

  • Related to Bug #5851: Exception found in XdmFunctionItem.call Message= added
Actions #4

Updated by O'Neil Delpratt almost 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
  • Found in version set to 12.0

I have made the change to the compile_stylesheet function to throw exception. This means that the user can catch any exception thrown.

Actions #5

Updated by Martin Honnen almost 2 years ago

I would like to know whether the newly introduced throw exception mechanism includes error details like error code, error line, error column position as exception properties if these details are available on the Java side.

In the current API for Python only the error message and the error code are reported to Python, important details like the error line number and the error line column are not exposed.

It would be nice if the new API with exceptions raises exceptions where such details are exposed/added to the exception if available from Saxon on the Java API level. Perhaps this is all already in there but I guess it doesn't hurt to ask now before a new release.

Actions #6

Updated by O'Neil Delpratt almost 2 years ago

  • Status changed from Resolved to In Progress

I will look into the issue of error codes and line numbers.

Actions #7

Updated by O'Neil Delpratt almost 2 years ago

  • Status changed from In Progress to Resolved

The C++ API the exception class includes the properties. I have added the error code and line number to the thrown Python exception as the error message.

Actions #8

Updated by O'Neil Delpratt almost 2 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 12.1

Bug fixed applied in the SaxonC 12.1 maintenance release.

Please register to edit this issue

Also available in: Atom PDF