Re: [basex-talk] Processing stack traces in XQuery code
Hi Omar, we’ve re-added the stack trace to the latest 11.0 snapshot [1], and will document this properly soon. I’ve slightly changed the behavior: Instead of a single descriptive string, the stack trace is now returned as a string sequence (the first entry points to the position in the code that failed, the following entries point to the function calls). I would like to see $err:stack-trace added to the standard. I’ll give you an update if the QT4 group confirms that this is a good idea (might take a while). Best, Christian [1] https://files.basex.org/releases/latest/ On Thu, Jan 11, 2024 at 12:15 PM Omar Siam wrote: > Hi, > > Until 10.6 one could find the stack trace of an error in > $err:additional. This feature is now gone from BaseX and the documentation. > > I made my life much easier with reporting stack traces on errors in > RestXQ endpoints. Now I don't see how to get that information anymore. > > Any advice how to get this functionality back? > > Best regards > > -- > Mag. Ing. Omar Siam > Austrian Center for Digital Humanities and Cultural Heritage > Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences > Stellvertretende Behindertenvertrauensperson | Deputy representative for > disabled persons > Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria > T: +43 1 51581-7295 > omar.s...@oeaw.ac.at | www.oeaw.ac.at/acdh > >
Re: [basex-talk] Processing stack traces in XQuery code
Hi Christian, So I already forgot about the first few lines of the message (I always cut them away). What I miss is the rest, the stack trace, the list of calls that got me to that line: I need something like `Stopped at { $err:module }, { $err:line-number }/{ $err:column-number }: { $err:description } { $err:stack-trace }` I create XML and JSON according to an RFC and I want to be able to have the trace there. I already use { $err:module }, { $err:line-number }, { $err:column-number } and { $err:description } E. g: https://tools.ietf.org/html/rfc7807/tests _:an-error: testError Test1 Test2 Test3 Test1 Test2 Test3 https://tools.ietf.org/html/rfc7807/tests/an-error 500 /app/tests/api-problem-rest-test.xqm, 38/10 - /app/tests/api-problem-rest-test.xqm, 34/16 - /app/tests/api-problem-rest-test.xqm, 30/15 - /app/tests/api-problem-rest-test.xqm, 26/15 - /app/tests/api-problem-rest-test.xqm, 21/58 - /app/api-problem/api-problem.xqm, 41/26 3.55 While in 10.7+ I only get https://tools.ietf.org/html/rfc7807/tests _:an-error: testError Test1 Test2 Test3 Test1 Test2 Test3 https://tools.ietf.org/html/rfc7807/tests/an-error 500 /app/tests/api-problem-rest-test.xqm, 38/10 2.15 See https://github.com/acdh-oeaw/api-problem4restxq/blob/master/tests/api-problem-rest-test.xqm#L15-L23 for details. There is a docker image using 10.6 for quick testing. docker run --rm -it -p 5000:5000 ghcr.io/acdh-oeaw/api-problem4restxq vs docker run --rm -it -p 5000:5000 ghcr.io/acdh-oeaw/api-problem4restxq:27f2a42 Look at to http://localhost:5000 Best regards Omar Am 12.01.2024 um 14:14 schrieb Christian Grün: Hi Omar, Thanks for your observation. We have removed the BaseX-specific string output, as it was redundant. You should be able to reproduce the old output as follows (using the new XQuery 4 string template syntax): `Stopped at { $err:module }, { $err:line-number }/{ $err:column-number }: { $err:description }` As you’ve already discovered the responsible commit, you may have discovered the new XQuery 4 $err:map variable: It bundles all other error values into a single variable. And @Martin Honnen thanks for mentioning fn:stack-trace. The function is still under discussion and might be dropped again: The specification gives processors much freedom in optimizing its expressions, so it’s hardly possible to define the function in a way that’s not completely implementation-defined. Hope this helps, Christian -- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295 omar.s...@oeaw.ac.at |www.oeaw.ac.at/acdh
Re: [basex-talk] Processing stack traces in XQuery code
Hi Omar, Thanks for your observation. We have removed the BaseX-specific string output, as it was redundant. You should be able to reproduce the old output as follows (using the new XQuery 4 string template syntax): `Stopped at { $err:module }, { $err:line-number }/{ $err:column-number }: { $err:description }` As you’ve already discovered the responsible commit, you may have discovered the new XQuery 4 $err:map variable: It bundles all other error values into a single variable. And @Martin Honnen thanks for mentioning fn:stack-trace. The function is still under discussion and might be dropped again: The specification gives processors much freedom in optimizing its expressions, so it’s hardly possible to define the function in a way that’s not completely implementation-defined. Hope this helps, Christian On Thu, Jan 11, 2024 at 12:52 PM Omar Siam wrote: > I think stack traces were removed in this commit from > basex-core/src/main/java/org/basex/query/expr/Catch.java > > Revision: fc2376f6c9c250babfac7a7161b8a61740878b2b > Author: Christian Grün > Date: 17.05.2023 11:25:01 > Message: > [XQ4] try/catch, $err:map > > > Modified: basex-api/src/main/java/org/basex/http/restxq/RestXqFunction.java > Modified: basex-core/src/main/java/org/basex/query/QueryParser.java > Modified: basex-core/src/main/java/org/basex/query/expr/Catch.java > Modified: basex-core/src/test/java/org/basex/query/expr/XQuery4Test.java > > line 141 -> 151 > qe.getMessage() is now replaced with an Empty.VALUE const. > > Am 11.01.2024 um 12:39 schrieb Martin Honnen: > > > > Am 11.01.2024 um 12:37 schrieb Omar Siam > : > > I get: Unknown function: fn:stack-trace() when I use stack-trace(). > > > Ah, sorry, it looks like it is not yet implemented. Wait for Christian to > give you hopefully some better info than my ill guess. > > > -- > Mag. Ing. Omar Siam > Austrian Center for Digital Humanities and Cultural Heritage > Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences > Stellvertretende Behindertenvertrauensperson | Deputy representative for > disabled persons > Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria > T: +43 1 51581-7295omar.s...@oeaw.ac.at | www.oeaw.ac.at/acdh > >
Re: [basex-talk] Processing stack traces in XQuery code
I think stack traces were removed in this commit from basex-core/src/main/java/org/basex/query/expr/Catch.java Revision: fc2376f6c9c250babfac7a7161b8a61740878b2b Author: Christian Grün Date: 17.05.2023 11:25:01 Message: [XQ4] try/catch, $err:map Modified: basex-api/src/main/java/org/basex/http/restxq/RestXqFunction.java Modified: basex-core/src/main/java/org/basex/query/QueryParser.java Modified: basex-core/src/main/java/org/basex/query/expr/Catch.java Modified: basex-core/src/test/java/org/basex/query/expr/XQuery4Test.java line 141 -> 151 qe.getMessage() is now replaced with an Empty.VALUE const. Am 11.01.2024 um 12:39 schrieb Martin Honnen: Am 11.01.2024 um 12:37 schrieb Omar Siam : I get: Unknown function: fn:stack-trace() when I use stack-trace(). Ah, sorry, it looks like it is not yet implemented. Wait for Christian to give you hopefully some better info than my ill guess. -- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295 omar.s...@oeaw.ac.at |www.oeaw.ac.at/acdh
Re: [basex-talk] Processing stack traces in XQuery code
> Am 11.01.2024 um 12:37 schrieb Omar Siam : > > I get: Unknown function: fn:stack-trace() when I use stack-trace(). > > Ah, sorry, it looks like it is not yet implemented. Wait for Christian to give you hopefully some better info than my ill guess.
Re: [basex-talk] Processing stack traces in XQuery code
I get: Unknown function: fn:stack-trace() when I use stack-trace(). I am not sure if this is meant as the equivalent of the stack trace where the error occured. This is what I got in the next catch block which might be anywhere, in my case in an unrelated module that implements a catch all and report functionality. Am 11.01.2024 um 12:19 schrieb Martin Honnen: Am 11.01.2024 um 12:15 schrieb Omar Siam : Hi, Until 10.6 one could find the stack trace of an error in $err:additional. This feature is now gone from BaseX and the documentation. I made my life much easier with reporting stack traces on errors in RestXQ endpoints. Now I don't see how to get that information anymore. Any advice how to get this functionality back? It might be that https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-stack-trace is already supported (but I haven´t checked). -- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295 omar.s...@oeaw.ac.at |www.oeaw.ac.at/acdh
Re: [basex-talk] Processing stack traces in XQuery code
> Am 11.01.2024 um 12:15 schrieb Omar Siam : > > Hi, > > Until 10.6 one could find the stack trace of an error in $err:additional. > This feature is now gone from BaseX and the documentation. > > I made my life much easier with reporting stack traces on errors in RestXQ > endpoints. Now I don't see how to get that information anymore. > > Any advice how to get this functionality back? It might be that https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-stack-trace is already supported (but I haven´t checked).