<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>17191</bug_id>
          
          <creation_ts>2012-05-25 17:27:33 +0000</creation_ts>
          <short_desc>[XQ30] (Too?) magic try/catch syntax</short_desc>
          <delta_ts>2012-06-26 13:30:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XQuery 3.0</component>
          <version>Working drafts</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>LATER</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="HB">hannesbauer</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>mike</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>68145</commentid>
    <comment_count>0</comment_count>
    <who name="HB">hannesbauer</who>
    <bug_when>2012-05-25 17:27:33 +0000</bug_when>
    <thetext>I&apos;m wondering if it&apos;s still possible to change the current try/catch syntax of XQuery 3.0?

Frankly, with all variables being magically assigned (afaik, something that happens nowhere else in XQuery), it&apos;s pretty inconvenient to pass on all error information to another function..

Current solution:
  try {
   123+&apos;456&apos;
  } catch * {
    local:handle-error($err:code, $err:description, $err:value, $err:module, $err:line-number, $err:column-number }
  }

Thus it would be great if 

a) the error could be bound to a specific variable, and/or
b) all information could be represented as a single element

Resulting queries could look as follows:

Query:
  declare function local:handle($error) { $error };
  try { 123+&apos;456&apos; } catch *($e) { local:handle($e) }

Result (brave proposal):
  &lt;XPTY0004 xmlns=&quot;http://www.w3.org/2005/xqt-errors&quot; line=&quot;4&quot; column=&quot;5&quot;&gt;
    Typing error: ...
  &lt;/XPTY0004&gt;

As I&apos;m probably throwing this in pretty late, maybe it is possible to extend the existing draft without endangering the existing functionality; e.g. by making the variable declaration optional, and adding yet another variable ($err:element?) that includes the values of most of the existing variables?

It&apos;s nice, however, that multiple error codes can be listed in one catch expression.

Thanks for your attention,
HB</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68186</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-05-27 11:34:45 +0000</bug_when>
    <thetext>This sounds like a good use case for maps, but sadly it seems maps aren&apos;t going to make it into XQuery 3.0. However, it wouldn&apos;t be impossible to add it later, with another variable $err:info that holds all the error information in the form of a map.

(personal response)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68280</commentid>
    <comment_count>2</comment_count>
    <who name="HB">hannesbauer</who>
    <bug_when>2012-05-29 18:57:33 +0000</bug_when>
    <thetext>Dear Michael Kay,

yes! I would like to see maps included in the specification soon; as far as I can judge, they would also be helpful new functions such as fn:serialize().

Back to try/catch: honestly, the current try/catch solution feels like a short term tradeoff to me (but I must confess I&apos;m no XQuery expert either). Do you think there&apos;s any chance that the current solution will be revised in time? What about introducing error variables in a future version of XQuery, as soon as there are maps available, too?

Thanks,
HB</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68282</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-05-29 21:32:35 +0000</bug_when>
    <thetext>Maps will not be available in XQuery 3.0. That means that we can&apos;t use a map-based solution in this timeframe.

XQuery 3.0 needs a way to report errors now. And we do have a solution that works.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69243</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-06-19 16:41:09 +0000</bug_when>
    <thetext>The WG has decided not to fix this in XQuery 3.0 In a later version of XQuery, when we have maps, we could add a variable that is bound to a map containing information about the error. 

I will create a corresponding bug in XQuery 3.1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69245</commentid>
    <comment_count>5</comment_count>
    <who name="Ghislain Fourny">g</who>
    <bug_when>2012-06-19 16:47:51 +0000</bug_when>
    <thetext>If this helps: I am afraid that some of the variables (err:value, err:additional) have type item()* (in theory, these could even be functions), which makes it impossible to embed them into an element. This is why using maps was considered.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69411</commentid>
    <comment_count>6</comment_count>
    <who name="HB">hannesbauer</who>
    <bug_when>2012-06-26 13:30:48 +0000</bug_when>
    <thetext>Hi Ghislain, thanks for the clarification. So let&apos;s just hope that XQuery 3.1 will be available soon (after all, more and more implementations seem to already offer their own maps implementations).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>