Merge lp:~zorba-coders/zorba/bug-1111786 into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Matthias Brantner
Approved revision: 11232
Merged at revision: 11230
Proposed branch: lp:~zorba-coders/zorba/bug-1111786
Merge into: lp:zorba
Diff against target: 1142 lines (+660/-99)
26 files modified
ChangeLog (+1/-0)
doc/zorba/errors_warnings.dox (+62/-9)
include/zorba/internal/diagnostic.h (+24/-0)
include/zorba/xquery_exception.h (+75/-0)
src/compiler/codegen/plan_visitor.cpp (+9/-0)
src/compiler/expression/expr.h (+3/-0)
src/compiler/translator/translator.cpp (+14/-1)
src/diagnostics/diagnostic.cpp (+9/-0)
src/diagnostics/diagnostic_en.xml (+4/-0)
src/diagnostics/pregenerated/dict_en.cpp (+1/-0)
src/diagnostics/pregenerated/dict_zed_keys.h (+1/-0)
src/diagnostics/xquery_exception.cpp (+52/-0)
src/diagnostics/xquery_exception.h (+106/-0)
src/runtime/core/trycatch.cpp (+88/-0)
src/runtime/core/trycatch.h (+3/-0)
src/runtime/json/common.cpp (+10/-0)
src/runtime/json/common.h (+7/-0)
src/runtime/json/json_impl.cpp (+53/-25)
src/runtime/json/json_loader.cpp (+69/-40)
src/store/naive/loader_fast.cpp (+26/-24)
test/rbkt/ExpQueryResults/zorba/error/data-location-json-1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/error/data-location-xml-1.xml.res (+1/-0)
test/rbkt/Queries/zorba/error/data-location-json-1.xq (+23/-0)
test/rbkt/Queries/zorba/error/data-location-xml-1.xq (+13/-0)
test/rbkt/Queries/zorba/error/data-location.json (+3/-0)
test/rbkt/Queries/zorba/error/data-location.xml (+2/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1111786
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+147020@code.launchpad.net

Commit message

Added $zerr:data-uri, $zerr:data-line-number, and $zerr:data-column-number.

Description of the change

Added $zerr:data-uri, $zerr:data-line-number, and $zerr:data-column-number.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1111786-2013-02-07T04-42-25.453Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve.

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

There are no tests

review: Needs Fixing
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Do I have to add the file-name to streamable strings for this?

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

I think we can make this a separate item.

On Feb 7, 2013, at 6:35 AM, Paul J. Lucas <email address hidden> wrote:

> Do I have to add the file-name to streamable strings for this?
> --
> https://code.launchpad.net/~zorba-coders/zorba/bug-1111786/+merge/147020
> You are reviewing the proposed merge of lp:~zorba-coders/zorba/bug-1111786 into lp:zorba.

lp:~zorba-coders/zorba/bug-1111786 updated
11229. By Paul J. Lucas

Added tests.

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

The code is good. However, the documentation of the variables should be added to doc/zorba/errors_warnings.dox (there is already a section that describes other available variables).

review: Needs Fixing
lp:~zorba-coders/zorba/bug-1111786 updated
11230. By Paul J. Lucas

Added documentation for mroe Zorba error variables.

11231. By Paul J. Lucas

Merge from trunk.

11232. By Paul J. Lucas

Said what "data file" means.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1111786-2013-02-09T01-38-50.87Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2013-02-08 23:40:49 +0000
+++ ChangeLog 2013-02-09 01:33:26 +0000
@@ -19,6 +19,7 @@
19Bug Fixes/Other Changes:19Bug Fixes/Other Changes:
20 * Fixed bug #867027 (XQST0059 error messages inconsistent)20 * Fixed bug #867027 (XQST0059 error messages inconsistent)
21 * Fixed bug #1095889 (Improve error message for xml-parsing error).21 * Fixed bug #1095889 (Improve error message for xml-parsing error).
22 * Fixed bug #1111786 (xml/json parse error location in catch clause).
22 * NaN items are considered equal to each other during grouping23 * NaN items are considered equal to each other during grouping
23 * Fixed bug #855481 (Too small time types on Windows).24 * Fixed bug #855481 (Too small time types on Windows).
24 * Fixed bug in computing the static type of an allowing-empty FOR variable.25 * Fixed bug in computing the static type of an allowing-empty FOR variable.
2526
=== modified file 'doc/zorba/errors_warnings.dox'
--- doc/zorba/errors_warnings.dox 2012-09-19 21:16:15 +0000
+++ doc/zorba/errors_warnings.dox 2013-02-09 01:33:26 +0000
@@ -57,18 +57,70 @@
57Please take a look at the C++ examples that show how to deal with errors and warnings in the C++ API (<a href="../../cxx/html/errors_8cpp-example.html">errors.cpp</a>).57Please take a look at the C++ examples that show how to deal with errors and warnings in the C++ API (<a href="../../cxx/html/errors_8cpp-example.html">errors.cpp</a>).
5858
59\section try_catch Try/Catch Expressions59\section try_catch Try/Catch Expressions
60The XQuery <a href="http://www.w3.org/TR/xquery-30/#id-try-catch">try/catch expression</a> provides error handling for dynamic errors and type errors raised during dynamic evaluation.60The XQuery
61For example,61<a href="http://www.w3.org/TR/xquery-30/#id-try-catch">try/catch expression</a>
62provides error handling for dynamic errors and type errors
63raised during dynamic evaluation.
64For example:
6265
63\include zorba/trycatch/trycatch_doc_example_01.xq66\include zorba/trycatch/trycatch_doc_example_01.xq
6467
65Withing the catch expression, a couple of implicit variables are declared.68Within the \c catch expression,
66Some of them (e.g.<tt>\$err:code</tt>, <tt>\$err:description</tt>, or <tt>\$err:line-number</tt>) are defined by the XQuery set of specifications.69a few implicit variables are defined.
67They are contained in XQuery's error namespace http://www.w3.org/2005/xqt-errors (prefix <tt>err</tt>).70Some of them
68Zorba defines an additional implicit variable that contains the stack trace of the error as an element.71(e.g., <tt>\$err:code</tt>,
69The name of the variable is <tt>\$zerr:stack-trace</tt> where the <tt>zerr</tt> prefix is bound to the namespace %http://www.zorba-xquery.com/errors.72<tt>\$err:description</tt>,
7073and <tt>\$err:line-number</tt>)
71For example, the query74are defined by the
75<a href="http://www.w3.org/TR/xquery-30/#id-try-catch">XQuery</a>
76specification.
77
78Zorba defines additional implicit variables:
79
80<table>
81 <tr>
82 <th>Variable</th>
83 <th>Type</th>
84 <th>Value</th>
85 </tr>
86 <tr>
87 <td>\c $zerr:data-uri</td>
88 <td>\c xs:string?</td>
89 <td>
90 The URI of the data file containing the error.
91 </td>
92 </tr>
93 <tr>
94 <td>\c $zerr:data-line-number</td>
95 <td>\c xs:integer?</td>
96 <td>
97 The line number within the data file where the error occurred.
98 The value \e may be approximate.
99 </td>
100 </tr>
101 <tr>
102 <td>\c $zerr:data-column-number</td>
103 <td>\c xs:integer?</td>
104 <td>
105 The column number within the data file where the error occurred.
106 The value \e may be approximate.
107 </td>
108 </tr>
109 <tr>
110 <td>\c $zerr:stack-trace</td>
111 <td>\c item()?</td>
112 <td>
113 The XQuery function call stack-trace
114 leading up to the error.
115 </td>
116 </tr>
117</table>
118
119where the \c zerr prefix
120is bound to the namespace \c %http://www.zorba-xquery.com/errors
121and "data file" refers to the file that data is being read from,
122e.g., the result of reading XML (<tt>fn:doc</tt>) or JSON data.
123For example, the query:
72124
73\code125\code
74declare namespace zerr = "http://www.zorba-xquery.com/errors";126declare namespace zerr = "http://www.zorba-xquery.com/errors";
@@ -107,3 +159,4 @@
107\endcode159\endcode
108160
109*/161*/
162/* vim:set et sw=2 ts=2: */
110163
=== modified file 'include/zorba/internal/diagnostic.h'
--- include/zorba/internal/diagnostic.h 2013-01-24 04:23:25 +0000
+++ include/zorba/internal/diagnostic.h 2013-02-09 01:33:26 +0000
@@ -200,10 +200,34 @@
200 line_type line_end_;200 line_type line_end_;
201 column_type column_end_;201 column_type column_end_;
202202
203 friend bool operator==( location const&, location const& );
204
203 // for plan serialization205 // for plan serialization
204 friend void serialization::operator&( serialization::Archiver&, location& );206 friend void serialization::operator&( serialization::Archiver&, location& );
205};207};
206208
209/**
210 * \internal
211 * Compares two locations for equality.
212 *
213 * @param i The first location.
214 * @param j The second location.
215 * @return Returns \c true only if the two locations are equal.
216 */
217bool operator==( location const &i, location const &j );
218
219/**
220 * \internal
221 * Compares two locations for inequality.
222 *
223 * @param i The first location.
224 * @param j The second location.
225 * @return Returns \c true only if the two locations are not equal.
226 */
227inline bool operator!=( location const &i, location const &j ) {
228 return !(i == j);
229}
230
207///////////////////////////////////////////////////////////////////////////////231///////////////////////////////////////////////////////////////////////////////
208232
209/**233/**
210234
=== modified file 'include/zorba/xquery_exception.h'
--- include/zorba/xquery_exception.h 2012-12-20 19:37:19 +0000
+++ include/zorba/xquery_exception.h 2013-02-09 01:33:26 +0000
@@ -138,6 +138,77 @@
138 return source_loc_.column_end();138 return source_loc_.column_end();
139 }139 }
140140
141 ////////// data file/line location //////////////////////////////////////////
142
143 /**
144 * Checks whether the XQuery data location has been set.
145 *
146 * @return Returns \c true only if the data location has been set.
147 */
148 bool has_data() const throw() {
149 return data_loc_;
150 }
151
152 /**
153 * Sets the XQuery source-code data URI name, line, and column numbers.
154 *
155 * @param uri The source-code data URI name. Must not be null.
156 * @param line The source-code data URI line number.
157 * @param column The source-code data URI column number.
158 * @param line_end The source-code data URI end line number.
159 * @param column_end The source-code data URI end column number.
160 */
161 void set_data( char const *uri,
162 line_type line,
163 column_type column = 0,
164 line_type line_end = 0,
165 column_type column_end = 0 );
166
167 /**
168 * Gets the data URI containing the error.
169 *
170 * @return Returns said URI or the empty string if unset.
171 */
172 char const* data_uri() const throw() {
173 return data_loc_.file();
174 }
175
176 /**
177 * Gets the data line number containing the error.
178 *
179 * @return Returns said line number or 0 if unset.
180 */
181 line_type data_line() const throw() {
182 return data_loc_.line();
183 }
184
185 /**
186 * Gets the data column number containing the error.
187 *
188 * @return Returns said column number or 0 if unset.
189 */
190 column_type data_column() const throw() {
191 return data_loc_.column();
192 }
193
194 /**
195 * Gets the data end line number containing the error.
196 *
197 * @return Returns said line number or 0 if unset.
198 */
199 line_type data_line_end() const throw() {
200 return data_loc_.line_end();
201 }
202
203 /**
204 * Gets the data end column number containing the error.
205 *
206 * @return Returns said column number or 0 if unset.
207 */
208 column_type data_column_end() const throw() {
209 return data_loc_.column_end();
210 }
211
141 ////////// "applied at" file/line location //////////////////////////////////212 ////////// "applied at" file/line location //////////////////////////////////
142213
143 /**214 /**
@@ -287,6 +358,7 @@
287 line_type raise_line, char const *message );358 line_type raise_line, char const *message );
288359
289 location source_loc_;360 location source_loc_;
361 location data_loc_;
290 location applied_loc_;362 location applied_loc_;
291 XQueryStackTrace query_trace_;363 XQueryStackTrace query_trace_;
292364
@@ -305,6 +377,9 @@
305 friend void set_applied( ZorbaException&, char const*, line_type, column_type,377 friend void set_applied( ZorbaException&, char const*, line_type, column_type,
306 line_type, column_type, bool );378 line_type, column_type, bool );
307379
380 friend void set_data( ZorbaException&, char const*, line_type, column_type,
381 line_type, column_type, bool );
382
308 friend void set_source( ZorbaException&, char const*, line_type, column_type,383 friend void set_source( ZorbaException&, char const*, line_type, column_type,
309 line_type, column_type, bool );384 line_type, column_type, bool );
310385
311386
=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp 2013-01-11 22:58:12 +0000
+++ src/compiler/codegen/plan_visitor.cpp 2013-02-09 01:33:26 +0000
@@ -2078,6 +2078,15 @@
2078 case catch_clause::err_column_no:2078 case catch_clause::err_column_no:
2079 rcc.theVars[TryCatchIterator::CatchClause::err_column_no] = *vec;2079 rcc.theVars[TryCatchIterator::CatchClause::err_column_no] = *vec;
2080 break;2080 break;
2081 case catch_clause::zerr_data_uri:
2082 rcc.theVars[TryCatchIterator::CatchClause::zerr_data_uri] = *vec;
2083 break;
2084 case catch_clause::zerr_data_line_no:
2085 rcc.theVars[TryCatchIterator::CatchClause::zerr_data_line_no] = *vec;
2086 break;
2087 case catch_clause::zerr_data_column_no:
2088 rcc.theVars[TryCatchIterator::CatchClause::zerr_data_column_no] = *vec;
2089 break;
2081 case catch_clause::zerr_stack_trace:2090 case catch_clause::zerr_stack_trace:
2082 rcc.theVars[TryCatchIterator::CatchClause::zerr_stack_trace] = *vec;2091 rcc.theVars[TryCatchIterator::CatchClause::zerr_stack_trace] = *vec;
2083 break;2092 break;
20842093
=== modified file 'src/compiler/expression/expr.h'
--- src/compiler/expression/expr.h 2013-01-11 22:58:12 +0000
+++ src/compiler/expression/expr.h 2013-02-09 01:33:26 +0000
@@ -949,6 +949,9 @@
949 err_module,949 err_module,
950 err_line_no,950 err_line_no,
951 err_column_no,951 err_column_no,
952 zerr_data_uri,
953 zerr_data_line_no,
954 zerr_data_column_no,
952 zerr_stack_trace955 zerr_stack_trace
953 };956 };
954957
955958
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-02-08 01:58:24 +0000
+++ src/compiler/translator/translator.cpp 2013-02-09 01:33:26 +0000
@@ -7851,7 +7851,8 @@
78517851
7852 push_scope();7852 push_scope();
78537853
7854 store::Item_t lCode, lDesc, lValue, lModule, lLineNo, lColumnNo, lStackTrace;7854 store::Item_t lCode, lDesc, lValue, lModule, lLineNo, lColumnNo,
7855 lDataURI, lDataLineNo, lDataColumnNo, lStackTrace;
78557856
7856 GENV_ITEMFACTORY->createQName(lCode, XQUERY_ERR_NS, "", "code");7857 GENV_ITEMFACTORY->createQName(lCode, XQUERY_ERR_NS, "", "code");
7857 GENV_ITEMFACTORY->createQName(lDesc, XQUERY_ERR_NS, "", "description");7858 GENV_ITEMFACTORY->createQName(lDesc, XQUERY_ERR_NS, "", "description");
@@ -7859,6 +7860,9 @@
7859 GENV_ITEMFACTORY->createQName(lModule, XQUERY_ERR_NS, "", "module");7860 GENV_ITEMFACTORY->createQName(lModule, XQUERY_ERR_NS, "", "module");
7860 GENV_ITEMFACTORY->createQName(lLineNo, XQUERY_ERR_NS, "", "line-number");7861 GENV_ITEMFACTORY->createQName(lLineNo, XQUERY_ERR_NS, "", "line-number");
7861 GENV_ITEMFACTORY->createQName(lColumnNo, XQUERY_ERR_NS, "", "column-number");7862 GENV_ITEMFACTORY->createQName(lColumnNo, XQUERY_ERR_NS, "", "column-number");
7863 GENV_ITEMFACTORY->createQName(lDataURI, ZORBA_ERR_NS, "", "data-uri");
7864 GENV_ITEMFACTORY->createQName(lDataLineNo, ZORBA_ERR_NS, "", "data-line-number");
7865 GENV_ITEMFACTORY->createQName(lDataColumnNo, ZORBA_ERR_NS, "", "data-column-number");
7862 GENV_ITEMFACTORY->createQName(lStackTrace, ZORBA_ERR_NS, "", "stack-trace");7866 GENV_ITEMFACTORY->createQName(lStackTrace, ZORBA_ERR_NS, "", "stack-trace");
78637867
7864 cc->add_var(catch_clause::err_code,7868 cc->add_var(catch_clause::err_code,
@@ -7879,6 +7883,15 @@
7879 cc->add_var(catch_clause::err_column_no,7883 cc->add_var(catch_clause::err_column_no,
7880 bind_var(loc, lColumnNo, var_expr::catch_var, theRTM.INTEGER_TYPE_QUESTION));7884 bind_var(loc, lColumnNo, var_expr::catch_var, theRTM.INTEGER_TYPE_QUESTION));
78817885
7886 cc->add_var(catch_clause::zerr_data_uri,
7887 bind_var(loc, lDataURI, var_expr::catch_var, theRTM.STRING_TYPE_QUESTION));
7888
7889 cc->add_var(catch_clause::zerr_data_line_no,
7890 bind_var(loc, lDataLineNo, var_expr::catch_var, theRTM.INTEGER_TYPE_QUESTION));
7891
7892 cc->add_var(catch_clause::zerr_data_column_no,
7893 bind_var(loc, lDataColumnNo, var_expr::catch_var, theRTM.INTEGER_TYPE_QUESTION));
7894
7882 cc->add_var(catch_clause::zerr_stack_trace,7895 cc->add_var(catch_clause::zerr_stack_trace,
7883 bind_var(loc, lStackTrace, var_expr::catch_var, theRTM.ITEM_TYPE_QUESTION));7896 bind_var(loc, lStackTrace, var_expr::catch_var, theRTM.ITEM_TYPE_QUESTION));
78847897
78857898
=== modified file 'src/diagnostics/diagnostic.cpp'
--- src/diagnostics/diagnostic.cpp 2013-01-24 05:48:07 +0000
+++ src/diagnostics/diagnostic.cpp 2013-02-09 01:33:26 +0000
@@ -176,6 +176,15 @@
176namespace diagnostic {176namespace diagnostic {
177177
178location const location::empty;178location const location::empty;
179
180bool operator==( location const &i, location const &j ) {
181 return i.file_ == j.file_
182 && i.line_ == j.line_
183 && i.column_ == j.column_
184 && i.line_end_ == j.line_end_
185 && i.column_end_ == j.column_end_;
186}
187
179parameters const parameters::empty;188parameters const parameters::empty;
180189
181#define case_123456789 \190#define case_123456789 \
182191
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-02-08 23:40:49 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-02-09 01:33:26 +0000
@@ -3470,6 +3470,10 @@
3470 <value>valid values are: yes, no, omit</value>3470 <value>valid values are: yes, no, omit</value>
3471 </entry>3471 </entry>
34723472
3473 <entry key="InData">
3474 <value>in data</value>
3475 </entry>
3476
3473 <entry key="IncompleteKeyInIndexBuild">3477 <entry key="IncompleteKeyInIndexBuild">
3474 <value>incomplete key during index build</value>3478 <value>incomplete key during index build</value>
3475 </entry>3479 </entry>
34763480
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-02-08 23:40:49 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-02-09 01:33:26 +0000
@@ -637,6 +637,7 @@
637 { "~GoodValuesAreXMLEtc", "valid values are: xml, html, xhtml, text, binary, json, jsoniq" },637 { "~GoodValuesAreXMLEtc", "valid values are: xml, html, xhtml, text, binary, json, jsoniq" },
638 { "~GoodValuesAreYesNo", "valid values are: yes, no" },638 { "~GoodValuesAreYesNo", "valid values are: yes, no" },
639 { "~GoodValuesAreYesNoOmit", "valid values are: yes, no, omit" },639 { "~GoodValuesAreYesNoOmit", "valid values are: yes, no, omit" },
640 { "~InData", "in data" },
640 { "~IncompleteKeyInIndexBuild", "incomplete key during index build" },641 { "~IncompleteKeyInIndexBuild", "incomplete key during index build" },
641 { "~IncompleteKeyInIndexRefresh", "incomplete key during index refresh" },642 { "~IncompleteKeyInIndexRefresh", "incomplete key during index refresh" },
642 { "~JNDY0021_IllegalCharacter_2", "'$2': illegal JSON character" },643 { "~JNDY0021_IllegalCharacter_2", "'$2': illegal JSON character" },
643644
=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h 2013-02-08 22:14:56 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-02-09 01:33:26 +0000
@@ -191,6 +191,7 @@
191#define ZED_GoodValuesAreXMLEtc "~GoodValuesAreXMLEtc"191#define ZED_GoodValuesAreXMLEtc "~GoodValuesAreXMLEtc"
192#define ZED_GoodValuesAreYesNo "~GoodValuesAreYesNo"192#define ZED_GoodValuesAreYesNo "~GoodValuesAreYesNo"
193#define ZED_GoodValuesAreYesNoOmit "~GoodValuesAreYesNoOmit"193#define ZED_GoodValuesAreYesNoOmit "~GoodValuesAreYesNoOmit"
194#define ZED_InData "~InData"
194#define ZED_IncompleteKeyInIndexBuild "~IncompleteKeyInIndexBuild"195#define ZED_IncompleteKeyInIndexBuild "~IncompleteKeyInIndexBuild"
195#define ZED_IncompleteKeyInIndexRefresh "~IncompleteKeyInIndexRefresh"196#define ZED_IncompleteKeyInIndexRefresh "~IncompleteKeyInIndexRefresh"
196#define ZED_LibModVersionMismatch_3 "~LibModVersionMismatch_3"197#define ZED_LibModVersionMismatch_3 "~LibModVersionMismatch_3"
197198
=== modified file 'src/diagnostics/xquery_exception.cpp'
--- src/diagnostics/xquery_exception.cpp 2013-02-07 03:15:48 +0000
+++ src/diagnostics/xquery_exception.cpp 2013-02-09 01:33:26 +0000
@@ -58,6 +58,7 @@
58XQueryException::XQueryException( XQueryException const &from ) :58XQueryException::XQueryException( XQueryException const &from ) :
59 ZorbaException( from ),59 ZorbaException( from ),
60 source_loc_( from.source_loc_ ),60 source_loc_( from.source_loc_ ),
61 data_loc_( from.data_loc_ ),
61 applied_loc_( from.applied_loc_ ),62 applied_loc_( from.applied_loc_ ),
62 query_trace_( from.query_trace_ )63 query_trace_( from.query_trace_ )
63{64{
@@ -84,6 +85,7 @@
84 if ( &from != this ) {85 if ( &from != this ) {
85 ZorbaException::operator=( from );86 ZorbaException::operator=( from );
86 source_loc_ = from.source_loc_;87 source_loc_ = from.source_loc_;
88 data_loc_ = from.data_loc_;
87 applied_loc_ = from.applied_loc_;89 applied_loc_ = from.applied_loc_;
88 query_trace_ = from.query_trace_;90 query_trace_ = from.query_trace_;
89 }91 }
@@ -109,6 +111,16 @@
109 applied_loc_.set( uri, line, col, line_end, col_end );111 applied_loc_.set( uri, line, col, line_end, col_end );
110}112}
111113
114void XQueryException::set_data( char const *uri,
115 line_type line,
116 column_type col,
117 line_type line_end,
118 column_type col_end ) {
119 if ( !uri || !*uri )
120 uri = source_loc_.file();
121 data_loc_.set( uri, line, col, line_end, col_end );
122}
123
112void XQueryException::set_source( char const *uri,124void XQueryException::set_source( char const *uri,
113 line_type line,125 line_type line,
114 column_type col,126 column_type col,
@@ -150,6 +162,16 @@
150#endif162#endif
151 o << "/>" << if_nl; // <location ...163 o << "/>" << if_nl; // <location ...
152164
165 if ( has_data() ) {
166 o << indent << "<data-location";
167 if ( data_uri() && ::strcmp( data_uri(), source_uri() ) != 0 )
168 print_uri( o, applied_uri() );
169 o << " line=\"" << data_line() << '"';
170 if ( data_column() )
171 o << " column=\"" << data_column() << '"';
172 o << "/>" << if_nl; // <data-location ...
173 }
174
153 if ( has_applied() ) {175 if ( has_applied() ) {
154 o << indent << "<applied-at";176 o << indent << "<applied-at";
155 if ( applied_uri() && ::strcmp( applied_uri(), source_uri() ) != 0 )177 if ( applied_uri() && ::strcmp( applied_uri(), source_uri() ) != 0 )
@@ -172,6 +194,18 @@
172 if ( source_column() )194 if ( source_column() )
173 o << "," << source_column();195 o << "," << source_column();
174196
197 if ( has_data() && data_loc_ != source_loc_ ) {
198 o << " (" << diagnostic::dict::lookup( ZED( InData ) ) << ' ';
199 if ( data_uri() && ::strcmp( data_uri(), source_uri() ) != 0 ) {
200 if ( print_uri( o, data_uri() ) )
201 o << ':';
202 }
203 o << data_line();
204 if ( data_column() )
205 o << ',' << data_column();
206 o << ')';
207 }
208
175 if ( has_applied() ) {209 if ( has_applied() ) {
176 o << " (" << diagnostic::dict::lookup( ZED( AppliedAt ) ) << ' ';210 o << " (" << diagnostic::dict::lookup( ZED( AppliedAt ) ) << ' ';
177 if ( applied_uri() && ::strcmp( applied_uri(), source_uri() ) != 0 ) {211 if ( applied_uri() && ::strcmp( applied_uri(), source_uri() ) != 0 ) {
@@ -341,6 +375,24 @@
341 }375 }
342}376}
343377
378void set_data( ZorbaException &ze, char const *file,
379 XQueryException::line_type line,
380 XQueryException::column_type col,
381 XQueryException::line_type line_end,
382 XQueryException::column_type col_end,
383 bool overwrite ) {
384 if ( XQueryException *const xe = dynamic_cast<XQueryException*>( &ze ) ) {
385 if ( !xe->has_data() || overwrite )
386 xe->set_data( file, line, col, line_end, col_end );
387 } else {
388 XQueryException new_xe(
389 ze.diagnostic(), ze.raise_file(), ze.raise_line(), ze.what()
390 );
391 new_xe.set_data( file, line, col, line_end, col_end );
392 throw new_xe;
393 }
394}
395
344void set_source( ZorbaException &ze, char const *file,396void set_source( ZorbaException &ze, char const *file,
345 XQueryException::line_type line,397 XQueryException::line_type line,
346 XQueryException::column_type col,398 XQueryException::column_type col,
347399
=== modified file 'src/diagnostics/xquery_exception.h'
--- src/diagnostics/xquery_exception.h 2013-02-05 04:53:32 +0000
+++ src/diagnostics/xquery_exception.h 2013-02-09 01:33:26 +0000
@@ -232,6 +232,112 @@
232 }232 }
233}233}
234234
235////////// XQuery diagnostic data location ////////////////////////////////////
236
237/**
238 * Sets the data location of the given ZorbaException but only if it's actually
239 * an XQueryException. If it's actually a ZorbaException, constructs a new
240 * XQueryException (copying the information from the ZorbaException) and throws
241 * it.
242 *
243 * @param ze The ZorbaException to set the location of.
244 * @param file The data file name.
245 * @param line The line number.
246 * @param col The column number.
247 * @param line_end The end line number.
248 * @param col_end The end column number.
249 * @param overwrite If \c false, sets the location only if the exception
250 * doesn't already have one; if \c true, always sets the location even if the
251 * exception already has one.
252 */
253void set_data( ZorbaException &ze, char const *file,
254 XQueryException::line_type line,
255 XQueryException::column_type col,
256 XQueryException::line_type line_end,
257 XQueryException::column_type col_end,
258 bool overwrite = true );
259
260/**
261 * Sets the data location of the given ZorbaException but only if it's actually
262 * an XQueryException. If it's actually a ZorbaException, constructs a new
263 * XQueryException (copying the information from the ZorbaException) and throws
264 * it.
265 *
266 * @tparam StringType The \a file string type.
267 * @param ze The ZorbaException to set the location of.
268 * @param file The data file name.
269 * @param line The line number.
270 * @param col The column number.
271 * @param line_end The end line number.
272 * @param col_end The end column number.
273 * @param overwrite If \c false, sets the location only if the exception
274 * doesn't already have one; if \c true, always sets the location even if the
275 * exception already has one.
276 */
277template<class StringType> inline
278void set_data( ZorbaException &ze, StringType const &file,
279 XQueryException::line_type line,
280 XQueryException::column_type col,
281 XQueryException::line_type line_end,
282 XQueryException::column_type col_end,
283 bool overwrite = true ) {
284 set_data( ze, file.c_str(), line, col, line_end, col_end, overwrite );
285}
286
287/**
288 * Sets the data location of the given ZorbaException but only if it's actually
289 * an XQueryException. If it's actually a ZorbaException, constructs a new
290 * XQueryException (copying the information from the ZorbaException) and throws
291 * it.
292 *
293 * @param ze The ZorbaException to set the location of.
294 * @param loc The query location.
295 * @param overwrite If \c false, sets the location only if the exception
296 * doesn't already have one; if \c true, always sets the location even if the
297 * exception already has one.
298 */
299inline void set_data( ZorbaException &ze, QueryLoc const &loc,
300 bool overwrite = true ) {
301 set_data(
302 ze,
303 loc.getFilename(),
304 loc.getLineBegin(),
305 loc.getColumnBegin(),
306 loc.getLineEnd(),
307 loc.getColumnEnd(),
308 overwrite
309 );
310}
311
312/**
313 * Sets the data location of the given ZorbaException but only if it's actually
314 * an XQueryException. If it's actually a ZorbaException, constructs a new
315 * XQueryException (copying the information from the ZorbaException) and throws
316 * it.
317 *
318 * @param to The ZorbaException to set the location of.
319 * @param from The ZorbaException to get the location from but only if it's
320 * actually an XQueryException.
321 * @param overwrite If \c false, sets the location only if the exception
322 * doesn't already have one; if \c true, always sets the location even if the
323 * exception already has one.
324 */
325inline void set_data( ZorbaException &to, ZorbaException const &from,
326 bool overwrite = true ) {
327 if ( XQueryException const *const xe =
328 dynamic_cast<XQueryException const*>( &from ) ) {
329 set_data(
330 to,
331 xe->data_uri(),
332 xe->data_line(),
333 xe->data_column(),
334 xe->data_line_end(),
335 xe->data_column_end(),
336 overwrite
337 );
338 }
339}
340
235////////// XQuery diagnostic "applied at" location ////////////////////////////341////////// XQuery diagnostic "applied at" location ////////////////////////////
236342
237/**343/**
238344
=== modified file 'src/runtime/core/trycatch.cpp'
--- src/runtime/core/trycatch.cpp 2012-10-08 12:09:36 +0000
+++ src/runtime/core/trycatch.cpp 2013-02-09 01:33:26 +0000
@@ -498,6 +498,94 @@
498 }498 }
499 break;499 break;
500 }500 }
501
502 case CatchClause::zerr_data_uri:
503 {
504 LetVarConstIter lErrorDataURIVarIter = lIter->second.begin();
505 LetVarConstIter const lErrorDataURIVarIterEnd = lIter->second.end();
506
507 for ( ; lErrorDataURIVarIter != lErrorDataURIVarIterEnd;
508 ++lErrorDataURIVarIter )
509 {
510 store::Iterator_t lErrorDataURIIter;
511
512 XQueryException const *const xe =
513 dynamic_cast<XQueryException const*>( &e );
514 if ( xe && xe->has_data() ) {
515 store::Item_t lErrorDataURIItem;
516 zstring uri( xe->data_uri() );
517 GENV_ITEMFACTORY->createString( lErrorDataURIItem, uri );
518 lErrorDataURIIter = new ItemIterator(lErrorDataURIItem);
519 }
520 else
521 {
522 lErrorDataURIIter = new ItemIterator();
523 }
524 lErrorDataURIIter->open();
525 state->theErrorIters.push_back(lErrorDataURIIter);
526 (*lErrorDataURIVarIter)->bind(lErrorDataURIIter, planState);
527 }
528 break;
529 }
530
531 case CatchClause::zerr_data_line_no:
532 {
533 LetVarConstIter lErrorDataLineVarIter = lIter->second.begin();
534 LetVarConstIter const lErrorDataLineVarIterEnd = lIter->second.end();
535
536 for ( ; lErrorDataLineVarIter != lErrorDataLineVarIterEnd;
537 ++lErrorDataLineVarIter )
538 {
539 store::Iterator_t lErrorDataLineIter;
540
541 XQueryException const *const xe =
542 dynamic_cast<XQueryException const*>( &e );
543 if ( xe && xe->has_data() ) {
544 store::Item_t lErrorDataLineItem;
545 GENV_ITEMFACTORY->createInteger(
546 lErrorDataLineItem, xs_integer(xe->data_line()));
547 lErrorDataLineIter = new ItemIterator(lErrorDataLineItem);
548 }
549 else
550 {
551 lErrorDataLineIter = new ItemIterator();
552 }
553 lErrorDataLineIter->open();
554 state->theErrorIters.push_back(lErrorDataLineIter);
555 (*lErrorDataLineVarIter)->bind(lErrorDataLineIter, planState);
556 }
557 break;
558 }
559
560 case CatchClause::zerr_data_column_no:
561 {
562 LetVarConstIter lErrorDataColumnVarIter = lIter->second.begin();
563 LetVarConstIter const lErrorDataColumnVarIterEnd = lIter->second.end();
564
565 for ( ; lErrorDataColumnVarIter != lErrorDataColumnVarIterEnd;
566 ++lErrorDataColumnVarIter )
567 {
568 store::Iterator_t lErrorDataColumnIter;
569
570 XQueryException const *const xe =
571 dynamic_cast<XQueryException const*>( &e );
572 if ( xe && xe->has_data() ) {
573 store::Item_t lErrorDataColumnItem;
574 GENV_ITEMFACTORY->createInteger(
575 lErrorDataColumnItem, xs_integer(xe->data_column()));
576 lErrorDataColumnIter = new ItemIterator(lErrorDataColumnItem);
577 }
578 else
579 {
580 lErrorDataColumnIter = new ItemIterator();
581 }
582 lErrorDataColumnIter->open();
583 state->theErrorIters.push_back(lErrorDataColumnIter);
584 (*lErrorDataColumnVarIter)->bind(lErrorDataColumnIter, planState);
585 }
586 break;
587 }
588
501 case CatchClause::zerr_stack_trace:589 case CatchClause::zerr_stack_trace:
502 {590 {
503 LetVarConstIter lStackTraceVarIter = lIter->second.begin();591 LetVarConstIter lStackTraceVarIter = lIter->second.begin();
504592
=== modified file 'src/runtime/core/trycatch.h'
--- src/runtime/core/trycatch.h 2012-09-19 21:16:15 +0000
+++ src/runtime/core/trycatch.h 2013-02-09 01:33:26 +0000
@@ -61,6 +61,9 @@
61 err_module,61 err_module,
62 err_line_no,62 err_line_no,
63 err_column_no,63 err_column_no,
64 zerr_data_uri,
65 zerr_data_line_no,
66 zerr_data_column_no,
64 zerr_stack_trace67 zerr_stack_trace
65 };68 };
6669
6770
=== modified file 'src/runtime/json/common.cpp'
--- src/runtime/json/common.cpp 2011-12-28 05:41:00 +0000
+++ src/runtime/json/common.cpp 2013-02-09 01:33:26 +0000
@@ -15,7 +15,10 @@
15 */15 */
16#include "stdafx.h"16#include "stdafx.h"
1717
18#include <zorba/xquery_exception.h>
19
18#include "store/api/iterator.h"20#include "store/api/iterator.h"
21#include "util/json_parser.h"
1922
20#include "common.h"23#include "common.h"
2124
@@ -42,6 +45,13 @@
42 return found;45 return found;
43}46}
4447
48void set_data( XQueryException *xe, json::exception const &je ) {
49 json::location const &loc( je.get_loc() );
50 xe->set_data(
51 loc.file(), loc.line(), loc.column(), loc.line_end(), loc.column_end()
52 );
53}
54
45///////////////////////////////////////////////////////////////////////////////55///////////////////////////////////////////////////////////////////////////////
4656
47#if ZORBA_DEBUG_JSON57#if ZORBA_DEBUG_JSON
4858
=== modified file 'src/runtime/json/common.h'
--- src/runtime/json/common.h 2013-02-01 06:03:17 +0000
+++ src/runtime/json/common.h 2013-02-09 01:33:26 +0000
@@ -30,6 +30,9 @@
3030
31namespace zorba {31namespace zorba {
3232
33class XQueryException;
34namespace json { class exception; }
35
33///////////////////////////////////////////////////////////////////////////////36///////////////////////////////////////////////////////////////////////////////
3437
35typedef std::stack<store::Item*> item_stack_type;38typedef std::stack<store::Item*> item_stack_type;
@@ -56,6 +59,10 @@
56bool get_attribute_value( store::Item_t const &element, char const *att_name,59bool get_attribute_value( store::Item_t const &element, char const *att_name,
57 zstring *att_value );60 zstring *att_value );
5861
62void set_data( XQueryException*, json::exception const& );
63
64typedef std::ostream& (*std_omanip_type)(std::ostream&);
65
59///////////////////////////////////////////////////////////////////////////////66///////////////////////////////////////////////////////////////////////////////
6067
61#define IN_STATE(S) ztd::top_stack_equals( state_stack, (S) )68#define IN_STATE(S) ztd::top_stack_equals( state_stack, (S) )
6269
=== modified file 'src/runtime/json/json_impl.cpp'
--- src/runtime/json/json_impl.cpp 2012-11-29 05:00:43 +0000
+++ src/runtime/json/json_impl.cpp 2013-02-09 01:33:26 +0000
@@ -103,50 +103,78 @@
103 ZORBA_ASSERT( false );103 ZORBA_ASSERT( false );
104 }104 }
105 catch ( json::illegal_character const &e ) {105 catch ( json::illegal_character const &e ) {
106 throw XQUERY_EXCEPTION(106 XQueryException xe(
107 zerr::ZJPE0001_ILLEGAL_CHARACTER,107 XQUERY_EXCEPTION(
108 ERROR_PARAMS( ascii::printable_char( e.get_char() ) ),108 zerr::ZJPE0001_ILLEGAL_CHARACTER,
109 ERROR_LOC( e.get_loc() )109 ERROR_PARAMS( ascii::printable_char( e.get_char() ) ),
110 ERROR_LOC( e.get_loc() )
111 )
110 );112 );
113 set_data( &xe, e );
114 throw xe;
111 }115 }
112 catch ( json::illegal_codepoint const &e ) {116 catch ( json::illegal_codepoint const &e ) {
113 throw XQUERY_EXCEPTION(117 XQueryException xe(
114 zerr::ZJPE0002_ILLEGAL_CODEPOINT,118 XQUERY_EXCEPTION(
115 ERROR_PARAMS( e.get_codepoint() ),119 zerr::ZJPE0002_ILLEGAL_CODEPOINT,
116 ERROR_LOC( e.get_loc() )120 ERROR_PARAMS( e.get_codepoint() ),
121 ERROR_LOC( e.get_loc() )
122 )
117 );123 );
124 set_data( &xe, e );
125 throw xe;
118 }126 }
119 catch ( json::illegal_escape const &e ) {127 catch ( json::illegal_escape const &e ) {
120 throw XQUERY_EXCEPTION(128 XQueryException xe(
121 zerr::ZJPE0003_ILLEGAL_ESCAPE,129 XQUERY_EXCEPTION(
122 ERROR_PARAMS( e.get_escape() ),130 zerr::ZJPE0003_ILLEGAL_ESCAPE,
123 ERROR_LOC( e.get_loc() )131 ERROR_PARAMS( e.get_escape() ),
132 ERROR_LOC( e.get_loc() )
133 )
124 );134 );
135 set_data( &xe, e );
136 throw xe;
125 }137 }
126 catch ( json::illegal_literal const &e ) {138 catch ( json::illegal_literal const &e ) {
127 throw XQUERY_EXCEPTION(139 XQueryException xe(
128 zerr::ZJPE0004_ILLEGAL_LITERAL,140 XQUERY_EXCEPTION(
129 ERROR_LOC( e.get_loc() )141 zerr::ZJPE0004_ILLEGAL_LITERAL,
142 ERROR_LOC( e.get_loc() )
143 )
130 );144 );
145 set_data( &xe, e );
146 throw xe;
131 }147 }
132 catch ( json::illegal_number const &e ) {148 catch ( json::illegal_number const &e ) {
133 throw XQUERY_EXCEPTION(149 XQueryException xe(
134 zerr::ZJPE0005_ILLEGAL_NUMBER,150 XQUERY_EXCEPTION(
135 ERROR_LOC( e.get_loc() )151 zerr::ZJPE0005_ILLEGAL_NUMBER,
152 ERROR_LOC( e.get_loc() )
153 )
136 );154 );
155 set_data( &xe, e );
156 throw xe;
137 }157 }
138 catch ( json::unexpected_token const &e ) {158 catch ( json::unexpected_token const &e ) {
139 throw XQUERY_EXCEPTION(159 XQueryException xe(
140 zerr::ZJPE0006_UNEXPECTED_TOKEN,160 XQUERY_EXCEPTION(
141 ERROR_PARAMS( e.get_token() ),161 zerr::ZJPE0006_UNEXPECTED_TOKEN,
142 ERROR_LOC( e.get_loc() )162 ERROR_PARAMS( e.get_token() ),
163 ERROR_LOC( e.get_loc() )
164 )
143 );165 );
166 set_data( &xe, e );
167 throw xe;
144 }168 }
145 catch ( json::unterminated_string const &e ) {169 catch ( json::unterminated_string const &e ) {
146 throw XQUERY_EXCEPTION(170 XQueryException xe(
147 zerr::ZJPE0007_UNTERMINATED_STRING,171 XQUERY_EXCEPTION(
148 ERROR_LOC( e.get_loc() )172 zerr::ZJPE0007_UNTERMINATED_STRING,
173 ERROR_LOC( e.get_loc() )
174 )
149 );175 );
176 set_data( &xe, e );
177 throw xe;
150 }178 }
151179
152 STACK_PUSH( !!result, state );180 STACK_PUSH( !!result, state );
153181
=== modified file 'src/runtime/json/json_loader.cpp'
--- src/runtime/json/json_loader.cpp 2012-12-03 18:29:05 +0000
+++ src/runtime/json/json_loader.cpp 2013-02-09 01:33:26 +0000
@@ -31,6 +31,7 @@
31#include "zorbatypes/zstring.h"31#include "zorbatypes/zstring.h"
3232
33// local33// local
34#include "common.h"
34#include "json_loader.h"35#include "json_loader.h"
3536
36using namespace std;37using namespace std;
@@ -206,65 +207,93 @@
206 return false;207 return false;
207 } // try208 } // try
208 catch ( json::illegal_character const &e ) {209 catch ( json::illegal_character const &e ) {
209 throw XQUERY_EXCEPTION(210 XQueryException xe(
210 jerr::JNDY0021,211 XQUERY_EXCEPTION(
211 ERROR_PARAMS(212 jerr::JNDY0021,
212 ZED( JNDY0021_IllegalCharacter_2 ),213 ERROR_PARAMS(
213 ascii::printable_char( e.get_char() )214 ZED( JNDY0021_IllegalCharacter_2 ),
214 ),215 ascii::printable_char( e.get_char() )
215 ERROR_LOC( e.get_loc() )216 ),
217 ERROR_LOC( e.get_loc() )
218 )
216 );219 );
220 set_data( &xe, e );
221 throw xe;
217 }222 }
218 catch ( json::illegal_codepoint const &e ) {223 catch ( json::illegal_codepoint const &e ) {
219 throw XQUERY_EXCEPTION(224 XQueryException xe(
220 jerr::JNDY0021,225 XQUERY_EXCEPTION(
221 ERROR_PARAMS(226 jerr::JNDY0021,
222 ZED( JNDY0021_IllegalCodepoint_2 ),227 ERROR_PARAMS(
223 e.get_codepoint()228 ZED( JNDY0021_IllegalCodepoint_2 ),
224 ),229 e.get_codepoint()
225 ERROR_LOC( e.get_loc() )230 ),
231 ERROR_LOC( e.get_loc() )
232 )
226 );233 );
234 set_data( &xe, e );
235 throw xe;
227 }236 }
228 catch ( json::illegal_escape const &e ) {237 catch ( json::illegal_escape const &e ) {
229 throw XQUERY_EXCEPTION(238 XQueryException xe(
230 jerr::JNDY0021,239 XQUERY_EXCEPTION(
231 ERROR_PARAMS(240 jerr::JNDY0021,
232 ZED( JNDY0021_IllegalEscape_2 ),241 ERROR_PARAMS(
233 ascii::printable_char( e.get_escape() )242 ZED( JNDY0021_IllegalEscape_2 ),
234 ),243 ascii::printable_char( e.get_escape() )
235 ERROR_LOC( e.get_loc() )244 ),
245 ERROR_LOC( e.get_loc() )
246 )
236 );247 );
248 set_data( &xe, e );
249 throw xe;
237 }250 }
238 catch ( json::illegal_literal const &e ) {251 catch ( json::illegal_literal const &e ) {
239 throw XQUERY_EXCEPTION(252 XQueryException xe(
240 jerr::JNDY0021,253 XQUERY_EXCEPTION(
241 ERROR_PARAMS( ZED( JNDY0021_IllegalLiteral ) ),254 jerr::JNDY0021,
242 ERROR_LOC( e.get_loc() )255 ERROR_PARAMS( ZED( JNDY0021_IllegalLiteral ) ),
256 ERROR_LOC( e.get_loc() )
257 )
243 );258 );
259 set_data( &xe, e );
260 throw xe;
244 }261 }
245 catch ( json::illegal_number const &e ) {262 catch ( json::illegal_number const &e ) {
246 throw XQUERY_EXCEPTION(263 XQueryException xe(
247 jerr::JNDY0021,264 XQUERY_EXCEPTION(
248 ERROR_PARAMS( ZED( JNDY0021_IllegalNumber ) ),265 jerr::JNDY0021,
249 ERROR_LOC( e.get_loc() )266 ERROR_PARAMS( ZED( JNDY0021_IllegalNumber ) ),
267 ERROR_LOC( e.get_loc() )
268 )
250 );269 );
270 set_data( &xe, e );
271 throw xe;
251 }272 }
252 catch ( json::unexpected_token const &e ) {273 catch ( json::unexpected_token const &e ) {
253 throw XQUERY_EXCEPTION(274 XQueryException xe(
254 jerr::JNDY0021,275 XQUERY_EXCEPTION(
255 ERROR_PARAMS(276 jerr::JNDY0021,
256 ZED( JNDY0021_UnexpectedToken_2 ),277 ERROR_PARAMS(
257 e.get_token()278 ZED( JNDY0021_UnexpectedToken_2 ),
258 ),279 e.get_token()
259 ERROR_LOC( e.get_loc() )280 ),
281 ERROR_LOC( e.get_loc() )
282 )
260 );283 );
284 set_data( &xe, e );
285 throw xe;
261 }286 }
262 catch ( json::unterminated_string const &e ) {287 catch ( json::unterminated_string const &e ) {
263 throw XQUERY_EXCEPTION(288 XQueryException xe(
264 jerr::JNDY0021,289 XQUERY_EXCEPTION(
265 ERROR_PARAMS( ZED( JNDY0021_UnterminatedString ) ),290 jerr::JNDY0021,
266 ERROR_LOC( e.get_loc() )291 ERROR_PARAMS( ZED( JNDY0021_UnterminatedString ) ),
292 ERROR_LOC( e.get_loc() )
293 )
267 );294 );
295 set_data( &xe, e );
296 throw xe;
268 }297 }
269}298}
270299
271300
=== modified file 'src/store/naive/loader_fast.cpp'
--- src/store/naive/loader_fast.cpp 2013-01-21 03:22:59 +0000
+++ src/store/naive/loader_fast.cpp 2013-02-09 01:33:26 +0000
@@ -145,30 +145,32 @@
145 XmlLoader *const loader = static_cast<XmlLoader*>( ctx );145 XmlLoader *const loader = static_cast<XmlLoader*>( ctx );
146 switch ( error->level ) {146 switch ( error->level ) {
147 case XML_ERR_ERROR:147 case XML_ERR_ERROR:
148 case XML_ERR_FATAL:148 case XML_ERR_FATAL: {
149 loader->theXQueryDiagnostics->add_error(149 XQueryException *const xe = NEW_XQUERY_EXCEPTION(
150 NEW_XQUERY_EXCEPTION(150 zerr::ZSTR0021_LOADER_PARSING_ERROR,
151 zerr::ZSTR0021_LOADER_PARSING_ERROR,151 ERROR_PARAMS(
152 ERROR_PARAMS(152 error->file, error->line, error->int2 /* column */,
153 error->file, error->line, error->int2 /* column */,153 libxml_dict_key_4, error_str1_5, error_str2_6, error_str3_7,
154 libxml_dict_key_4, error_str1_5, error_str2_6, error_str3_7,154 error_int1_8, error_message_9
155 error_int1_8, error_message_9155 )
156 )156 );
157 )157 xe->set_data( error->file, error->line, error->int2 /* column */ );
158 );158 loader->theXQueryDiagnostics->add_error( xe );
159 break;159 break;
160 case XML_ERR_WARNING:160 }
161 loader->theXQueryDiagnostics->add_warning(161 case XML_ERR_WARNING: {
162 NEW_XQUERY_WARNING(162 XQueryWarning *const xw = NEW_XQUERY_WARNING(
163 zwarn::ZWST0007_LOADER_PARSING_WARNING,163 zwarn::ZWST0007_LOADER_PARSING_WARNING,
164 WARN_PARAMS(164 WARN_PARAMS(
165 error->file, error->line, error->int2 /* column */,165 error->file, error->line, error->int2 /* column */,
166 libxml_dict_key_4, error_str1_5, error_str2_6, error_str3_7,166 libxml_dict_key_4, error_str1_5, error_str2_6, error_str3_7,
167 error_int1_8, error_message_9167 error_int1_8, error_message_9
168 )168 )
169 )169 );
170 );170 xw->set_data( error->file, error->line, error->int2 /* column */ );
171 break;171 loader->theXQueryDiagnostics->add_warning( xw );
172 break;
173 }
172 default:174 default:
173 ZORBA_ASSERT( false );175 ZORBA_ASSERT( false );
174 } // switch176 } // switch
175177
=== added file 'test/rbkt/ExpQueryResults/zorba/error/data-location-json-1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/error/data-location-json-1.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/error/data-location-json-1.xml.res 2013-02-09 01:33:26 +0000
@@ -0,0 +1,1 @@
1. 3 1
02
=== added file 'test/rbkt/ExpQueryResults/zorba/error/data-location-xml-1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/error/data-location-xml-1.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/error/data-location-xml-1.xml.res 2013-02-09 01:33:26 +0000
@@ -0,0 +1,1 @@
1data-location.xml 3 1
02
=== added file 'test/rbkt/Queries/zorba/error/data-location-json-1.xq'
--- test/rbkt/Queries/zorba/error/data-location-json-1.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/error/data-location-json-1.xq 2013-02-09 01:33:26 +0000
@@ -0,0 +1,23 @@
1import module namespace file = "http://expath.org/ns/file";
2import module namespace jn = "http://jsoniq.org/functions";
3declare namespace zerr = "http://www.zorba-xquery.com/errors";
4
5let $file := "$RBKT_SRC_DIR/Queries/zorba/error/data-location.json"
6let $json := file:read-text( $file )
7return
8 try {
9 jn:parse-json( $json )
10 }
11 catch * {
12 (:
13 : This "if" is here temporarily until streamable strings have their
14 : filenames passed along with them.
15 :)
16 if ( exists( $zerr:data-uri ) )
17 then file:base-name( $zerr:data-uri )
18 else (),
19 $zerr:data-line-number,
20 $zerr:data-column-number
21 }
22
23(: vim:set et sw=2 ts=2: :)
024
=== added file 'test/rbkt/Queries/zorba/error/data-location-xml-1.xq'
--- test/rbkt/Queries/zorba/error/data-location-xml-1.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/error/data-location-xml-1.xq 2013-02-09 01:33:26 +0000
@@ -0,0 +1,13 @@
1import module namespace file = "http://expath.org/ns/file";
2declare namespace zerr = "http://www.zorba-xquery.com/errors";
3
4try {
5 fn:doc( "data-location.xml" )
6}
7catch * {
8 file:base-name( $zerr:data-uri ),
9 $zerr:data-line-number,
10 $zerr:data-column-number
11}
12
13(: vim:set et sw=2 ts=2: :)
014
=== added file 'test/rbkt/Queries/zorba/error/data-location.json'
--- test/rbkt/Queries/zorba/error/data-location.json 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/error/data-location.json 2013-02-09 01:33:26 +0000
@@ -0,0 +1,3 @@
1{
2 "key" : 42,
3}
04
=== added file 'test/rbkt/Queries/zorba/error/data-location.xml'
--- test/rbkt/Queries/zorba/error/data-location.xml 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/error/data-location.xml 2013-02-09 01:33:26 +0000
@@ -0,0 +1,2 @@
1<!-- terminating '>' is intentionally missing -->
2<msg>hello, world!</msg

Subscribers

People subscribed via source and target branches