← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/bug-867027 into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/bug-867027 into lp:zorba.

Commit message:
Created new error codes to handle errors other than what XQST0059 was intended for.

Requested reviews:
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #867027 in Zorba: "XQST0059 error messages inconsistent"
  https://bugs.launchpad.net/zorba/+bug/867027

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/bug-867027/+merge/147257

Created new error codes to handle errors other than what XQST0059 was intended for.
-- 
https://code.launchpad.net/~paul-lucas/zorba/bug-867027/+merge/147257
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2013-02-03 17:44:39 +0000
+++ ChangeLog	2013-02-08 00:14:22 +0000
@@ -15,6 +15,7 @@
     collection).
 
 Bug Fixes/Other Changes:
+  * Fixed bug #867027 (XQST0059 error messages inconsistent)
   * Fixed bug #1095889 (Improve error message for xml-parsing error).
   * NaN items are considered equal to each other during grouping
   * Fixed bug #855481 (Too small time types on Windows).

=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h	2013-01-23 17:24:44 +0000
+++ include/zorba/pregenerated/diagnostic_list.h	2013-02-08 00:14:22 +0000
@@ -422,6 +422,8 @@
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0013_FXCHARHEAP_EXCEPTION;
 
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0014_OUT_OF_MEMORY;
+
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0016_RESERVED_MODULE_TARGET_NAMESPACE;
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0017_FILE_ACCESS_DISABLED;
@@ -446,6 +448,12 @@
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0032_ERROR_TRANSFORMING_XQUERYX_TO_XQUERY;
 
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0033_SCHEMA_XML_ERROR;
+
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0034_SCHEMA_ERROR;
+
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0035_SCHEMA_UNEXPECTED_ERROR;
+
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0036_BREAKITERATOR_CREATION_FAILED;
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZXQP0037_INAPPROPRIATE_MODULE_VERSION;

=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq	2013-01-08 00:31:47 +0000
+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq	2013-02-08 00:14:22 +0000
@@ -113,6 +113,10 @@
 
 (:~
 :)
+declare variable $zerr:ZXQP0014 as xs:QName := fn:QName($zerr:NS, "zerr:ZXQP0014");
+
+(:~
+:)
 declare variable $zerr:ZXQP0016 as xs:QName := fn:QName($zerr:NS, "zerr:ZXQP0016");
 
 (:~
@@ -161,6 +165,18 @@
 
 (:~
 :)
+declare variable $zerr:ZXQP0033 as xs:QName := fn:QName($zerr:NS, "zerr:ZXQP0033");
+
+(:~
+:)
+declare variable $zerr:ZXQP0034 as xs:QName := fn:QName($zerr:NS, "zerr:ZXQP0034");
+
+(:~
+:)
+declare variable $zerr:ZXQP0035 as xs:QName := fn:QName($zerr:NS, "zerr:ZXQP0035");
+
+(:~
+:)
 declare variable $zerr:ZXQP0036 as xs:QName := fn:QName($zerr:NS, "zerr:ZXQP0036");
 
 (:~

=== modified file 'modules/w3c/pregenerated/xqt-errors.xq'
--- modules/w3c/pregenerated/xqt-errors.xq	2013-01-19 20:47:55 +0000
+++ modules/w3c/pregenerated/xqt-errors.xq	2013-02-08 00:14:22 +0000
@@ -420,8 +420,8 @@
 
 (:~
  :
- : It is a static error if a schema import binds a namespace prefix but does
- : not specify a target namespace other than a zero-length string.
+ : It is a static error if a schema import binds a namespace prefix but
+ : does not specify a target namespace other than a zero-length string.
  : 
  : @see http://www.w3.org/2005/xqt-errors
 :)
@@ -439,8 +439,8 @@
 (:~
  :
  : It is a static error if an implementation is unable to process a schema
- : or module import by finding a schema or module with the specified target
- : namespace.
+ : or module import by finding a schema or module with the specified
+ : target namespace.
  : 
  : @see http://www.w3.org/2005/xqt-errors
 :)

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2013-01-29 06:01:31 +0000
+++ src/compiler/translator/translator.cpp	2013-02-08 00:14:22 +0000
@@ -2197,7 +2197,7 @@
     }
 
     if ( lStream == NULL ) {
-      throw XQUERY_EXCEPTION(err::XQST0059, ERROR_PARAMS(lNsURI, lErrorMessage));
+      throw XQUERY_EXCEPTION(err::XQST0059, ERROR_PARAMS(lNsURI, "", lErrorMessage));
     }
 
     // If we got this far, we have a valid StreamResource.

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2013-02-03 19:01:15 +0000
+++ src/diagnostics/diagnostic_en.xml	2013-02-08 00:14:22 +0000
@@ -572,27 +572,27 @@
 
     <diagnostic code="XQST0057">
       <comment>
-       It is a static error if a schema import binds a namespace prefix but does
-       not specify a target namespace other than a zero-length string.
+        It is a static error if a schema import binds a namespace prefix but
+        does not specify a target namespace other than a zero-length string.
       </comment>
       <value>empty target namespace</value>
     </diagnostic>
 
     <diagnostic code="XQST0058">
       <comment>
-       It is a static error if multiple schema imports specify the same target
-       namespace.
+        It is a static error if multiple schema imports specify the same target
+        namespace.
       </comment>
       <value>"$1": duplicate target namespace</value>
     </diagnostic>
 
     <diagnostic code="XQST0059">
       <comment>
-       It is a static error if an implementation is unable to process a schema
-       or module import by finding a schema or module with the specified target
-       namespace.
+        It is a static error if an implementation is unable to process a schema
+        or module import by finding a schema or module with the specified
+        target namespace.
       </comment>
-      <value>"$1": target namespace not found for schema/module${ 2}</value>
+      <value>"$1": target namespace not found for schema/module${ "2"}${: 3}</value>
     </diagnostic>
 
     <diagnostic code="XQST0060">
@@ -1964,6 +1964,10 @@
       <value>FxCharHeap error: $1 ($2)</value>
     </diagnostic>
 
+    <diagnostic code="ZXQP0014" name="OUT_OF_MEMORY">
+      <value>${"1": }out of memory${: 2}</value>
+    </diagnostic>
+
     <diagnostic code="ZXQP0016" name="RESERVED_MODULE_TARGET_NAMESPACE">
       <value>"$1": reserved module target namespace</value>
     </diagnostic>
@@ -1986,7 +1990,6 @@
 
     <diagnostic code="ZXQP0025" name="COULD_NOT_FETCH_RESOURCE">
       <value>"$1": could not fetch resource${; reason: 2}</value>
-
       <entry key="RESOURCE_NOT_FOUND">
         <value>resource not found</value>
       </entry>
@@ -2016,6 +2019,18 @@
       <value>error transforming XQueryX to XQuery${: 1}</value>
     </diagnostic>
 
+    <diagnostic code="ZXQP0033" name="SCHEMA_XML_ERROR">
+      <value>${"1": }XML error in schema${: 2}</value>
+    </diagnostic>
+
+    <diagnostic code="ZXQP0034" name="SCHEMA_ERROR">
+      <value>$1,$2: error in schema${ with System ID "3"}${ with Public ID "4"}${: 5}</value>
+    </diagnostic>
+
+    <diagnostic code="ZXQP0035" name="SCHEMA_UNEXPECTED_ERROR">
+      <value>${"1": }unexpected error in schema${: 2}</value>
+    </diagnostic>
+
     <diagnostic code="ZXQP0036" name="BREAKITERATOR_CREATION_FAILED">
       <value>BreakIterator creation failed</value>
     </diagnostic>
@@ -2037,9 +2052,7 @@
     </diagnostic>
 
     <diagnostic code="ZXQP0050" name="FEATURE_NOT_AVAILABLE">
-
       <value>"$1": feature not available</value>
-
     </diagnostic>
 
     <diagnostic code="ZXQP0060" name="OPTION_NOT_KNOWN">
@@ -3719,14 +3732,6 @@
       <value>the standalone attribute has a value other than "omit"</value>
     </entry>
 
-    <entry key="SchemaOutOfMemory">
-      <value>OutOfMemoryException during parsing</value>
-    </entry>
-
-    <entry key="SchemaParseError">
-      <value>error during parsing</value>
-    </entry>
-
     <entry key="SchemaUnexpected">
       <value>unexpected exception during parsing</value>
     </entry>

=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp	2013-01-23 17:24:44 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp	2013-02-08 00:14:22 +0000
@@ -613,6 +613,9 @@
 ZorbaErrorCode ZXQP0013_FXCHARHEAP_EXCEPTION( "ZXQP0013" );
 
 
+ZorbaErrorCode ZXQP0014_OUT_OF_MEMORY( "ZXQP0014" );
+
+
 ZorbaErrorCode ZXQP0016_RESERVED_MODULE_TARGET_NAMESPACE( "ZXQP0016" );
 
 
@@ -649,6 +652,15 @@
 ZorbaErrorCode ZXQP0032_ERROR_TRANSFORMING_XQUERYX_TO_XQUERY( "ZXQP0032" );
 
 
+ZorbaErrorCode ZXQP0033_SCHEMA_XML_ERROR( "ZXQP0033" );
+
+
+ZorbaErrorCode ZXQP0034_SCHEMA_ERROR( "ZXQP0034" );
+
+
+ZorbaErrorCode ZXQP0035_SCHEMA_UNEXPECTED_ERROR( "ZXQP0035" );
+
+
 ZorbaErrorCode ZXQP0036_BREAKITERATOR_CREATION_FAILED( "ZXQP0036" );
 
 

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2013-02-03 19:01:15 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2013-02-08 00:14:22 +0000
@@ -230,7 +230,7 @@
   { "XQST0055", "multiple copy-namespaces declarations" },
   { "XQST0057", "empty target namespace" },
   { "XQST0058", "\"$1\": duplicate target namespace" },
-  { "XQST0059", "\"$1\": target namespace not found for schema/module${ 2}" },
+  { "XQST0059", "\"$1\": target namespace not found for schema/module${ \"2\"}${: 3}" },
   { "XQST0060", "\"$1\": function name has a null namespace URI" },
   { "XQST0065", "multiple ordering mode declaraions" },
   { "XQST0066", "multiple element/type/function namespace declarations" },
@@ -498,6 +498,7 @@
   { "ZXQP0011", "\"$1\": invalid locale" },
   { "ZXQP0012", "\"$1\": unknown locale" },
   { "ZXQP0013", "FxCharHeap error: $1 ($2)" },
+  { "ZXQP0014", "${\"1\": }out of memory${: 2}" },
   { "ZXQP0016", "\"$1\": reserved module target namespace" },
   { "ZXQP0017", "file access disabled" },
   { "ZXQP0020", "\"$1\": invalid URI${: 2}" },
@@ -510,6 +511,9 @@
   { "ZXQP0030", "deadlock" },
   { "ZXQP0031", "malformed XQueryX XML input${: 1}" },
   { "ZXQP0032", "error transforming XQueryX to XQuery${: 1}" },
+  { "ZXQP0033", "${\"1\": }XML error in schema${: 2}" },
+  { "ZXQP0034", "$1,$2: error in schema${ with System ID \"3\"}${ with Public ID \"4\"}${: 5}" },
+  { "ZXQP0035", "${\"1\": }unexpected error in schema${: 2}" },
   { "ZXQP0036", "BreakIterator creation failed" },
   { "ZXQP0037", "\"$1\": loaded module version \"$2\" does not match import version specification" },
   { "ZXQP0038", "Query requires Zorba version \"$1\"; you are running Zorba \"$2\"" },
@@ -799,8 +803,6 @@
 #endif
   { "~SEPM0009_Not10", "the version parameter has a value other than \"1.0\" and the doctype-system parameter is specified" },
   { "~SEPM0009_NotOmit", "the standalone attribute has a value other than \"omit\"" },
-  { "~SchemaOutOfMemory", "OutOfMemoryException during parsing" },
-  { "~SchemaParseError", "error during parsing" },
   { "~SchemaUnexpected", "unexpected exception during parsing" },
   { "~SearchKeyTypeMismatch_234", "\"$2\": search key type for index \"$3\" does not match expected type \"$4\"" },
   { "~SearchKeyTypeNoProbeIndex_23", "\"$2\": search key type can not probe index \"$3\"" },

=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h	2013-02-03 19:01:15 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h	2013-02-08 00:14:22 +0000
@@ -255,8 +255,6 @@
 #define ZED_QuotedColon_23 "~QuotedColon_23"
 #define ZED_SEPM0009_Not10 "~SEPM0009_Not10"
 #define ZED_SEPM0009_NotOmit "~SEPM0009_NotOmit"
-#define ZED_SchemaOutOfMemory "~SchemaOutOfMemory"
-#define ZED_SchemaParseError "~SchemaParseError"
 #define ZED_SchemaUnexpected "~SchemaUnexpected"
 #define ZED_SearchKeyTypeMismatch_234 "~SearchKeyTypeMismatch_234"
 #define ZED_SearchKeyTypeNoProbeIndex_23 "~SearchKeyTypeNoProbeIndex_23"

=== modified file 'src/types/schema/LoadSchemaErrorHandler.cpp'
--- src/types/schema/LoadSchemaErrorHandler.cpp	2012-09-19 21:16:15 +0000
+++ src/types/schema/LoadSchemaErrorHandler.cpp	2013-02-08 00:14:22 +0000
@@ -51,41 +51,20 @@
 void LoadSchemaErrorHandler::error(const XERCES_CPP_NAMESPACE::SAXParseException& e)
 {
   theSawErrors = true;
-  std::ostringstream os;
-  os << "Error in schema ";
-
-if ( e.getSystemId() != NULL )
-    os << "with system id " << StrX(e.getSystemId());
-  else if ( e.getPublicId() != NULL )
-    os << "with public id " << StrX(e.getPublicId());
-  else 
-    os << "without id"; 
-  
-  os << ", line " << e.getLineNumber() 
-     << ", column " << e.getColumnNumber() << "." << std::endl
-     << StrX(e.getMessage());
-
-  throw XQUERY_EXCEPTION( err::XQST0059, ERROR_PARAMS(os.str()), ERROR_LOC(theQueryLoc) );
+  throw XQUERY_EXCEPTION(
+    zerr::ZXQP0034_SCHEMA_ERROR,
+    ERROR_PARAMS(
+      e.getLineNumber(), e.getColumnNumber(),
+      e.getSystemId(), e.getPublicId(),
+      e.getMessage()
+    ),
+    ERROR_LOC( theQueryLoc )
+  );
 }
 
 void LoadSchemaErrorHandler::fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& e)
 {
-  theSawErrors = true;
-  std::ostringstream os;
-  os << "Fatal error in schema ";
-
-  if ( e.getSystemId() != NULL )
-    os << "with system id " << StrX(e.getSystemId());
-  else if ( e.getPublicId() != NULL )
-    os << "with public id " << StrX(e.getPublicId());
-  else 
-    os << "without id"; 
-  
-  os << ", line " << e.getLineNumber() 
-     << ", column " << e.getColumnNumber() << "." << std::endl
-     << StrX(e.getMessage());
-
-  throw XQUERY_EXCEPTION( err::XQST0059, ERROR_PARAMS(os.str()), ERROR_LOC(theQueryLoc) );
+  error( e );
 }
 
 void LoadSchemaErrorHandler::warning(const XERCES_CPP_NAMESPACE::SAXParseException& e)

=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp	2013-01-24 10:49:06 +0000
+++ src/types/schema/schema.cpp	2013-02-08 00:14:22 +0000
@@ -478,25 +478,31 @@
   }
   catch (const OutOfMemoryException&)
   {
-    throw XQUERY_EXCEPTION( err::XQST0059,
-        ERROR_PARAMS( std::string(xsdURL), ZED( SchemaOutOfMemory )),
-        ERROR_LOC( loc ) );
+    throw XQUERY_EXCEPTION(
+      zerr::ZXQP0014_OUT_OF_MEMORY,
+      ERROR_PARAMS( xsdURL ),
+      ERROR_LOC( loc )
+    );
   }
   catch (const XMLException& e)
   {
-    throw XQUERY_EXCEPTION( err::XQST0059,
-        ERROR_PARAMS( std::string(xsdURL), ZED( SchemaParseError ), StrX(e.getMessage())),
-        ERROR_LOC( loc ) );
+    throw XQUERY_EXCEPTION(
+      zerr::ZXQP0033_SCHEMA_XML_ERROR,
+      ERROR_PARAMS( xsdURL, e.getMessage() ),
+      ERROR_LOC( loc )
+    );
   }
-  catch (const ZorbaException& /* e */)
+  catch (const ZorbaException&)
   {
     throw;
   }
   catch (...)
   {
-    throw XQUERY_EXCEPTION( err::XQST0059,
-        ERROR_PARAMS( std::string(xsdURL), ZED( SchemaUnexpected )),
-        ERROR_LOC( loc ) );
+    throw XQUERY_EXCEPTION(
+      zerr::ZXQP0035_SCHEMA_UNEXPECTED_ERROR,
+      ERROR_PARAMS( xsdURL ),
+      ERROR_LOC( loc )
+    );
   }
 
 #ifdef DO_PRINT_SCHEMA_INFO


Follow ups