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

Commit message:
Fixed incorrect error reporting

Requested reviews:
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #1108515 in Zorba: "English error message in json_items.cpp"
  https://bugs.launchpad.net/zorba/+bug/1108515

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

Fixed incorrect error reporting
-- 
https://code.launchpad.net/~paul-lucas/zorba/bug-1108515/+merge/146316
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2013-01-30 15:19:38 +0000
+++ src/diagnostics/diagnostic_en.xml	2013-02-03 19:03:19 +0000
@@ -2735,7 +2735,13 @@
     </diagnostic>
 
     <diagnostic code="ZSTR0060" name="RANGE_EXCEPTION">
-      <value>out of range: $1</value>
+      <value>"$1": value out of range${ 2}</value>
+      <entry key="ForCollection_3">
+        <value>for collection "$3"</value>
+      </entry>
+      <entry key="ForSequence">
+        <value>for sequence</value>
+      </entry>
     </diagnostic>
 
     <diagnostic code="ZSTR0065" name="STRINGS_IN_POOL">

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2013-01-30 16:43:55 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2013-02-03 19:03:19 +0000
@@ -469,7 +469,7 @@
   { "ZSTR0045", "duplicate node found in sequence" },
   { "ZSTR0050", "\"$1\" not implemented for item type \"$2\"" },
   { "ZSTR0055", "streamable string has already been consumed" },
-  { "ZSTR0060", "out of range: $1" },
+  { "ZSTR0060", "\"$1\": value out of range${ 2}" },
   { "ZSTR0065", "Zorba did not close properly, objects may still in memory.\\n$1 referenced URI(s) remain in the string pool.\\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks." },
   { "ZSTR0066", "$1: does not reference a node in collection $2" },
   { "ZWST0002", "\"$1\": unknown or unsupported annotation" },
@@ -935,6 +935,8 @@
   { "~ZDST0027_NO_KEY_TYPE_DECL", "value index missing key type declaration" },
   { "~ZDST0060_unknown_localname", "unknown localname ($3)" },
   { "~ZDST0060_unknown_namespace", "unknown namespace ($3)" },
+  { "~ZSTR0060_ForCollection_3", "for collection \"$3\"" },
+  { "~ZSTR0060_ForSequence", "for sequence" },
   { "~ZWST0005_PARAM_TYPE", "type of parameter $3 is $4 which is not a subtype of xs:anyAtomicType" },
   { "~ZWST0005_RETURN_TYPE", "return type ($3) is not subtype of xs:anyAtomicType" },
   { "~ZWST0005_UPDATING", "function is updating" },

=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h	2013-01-23 17:24:44 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h	2013-02-03 19:03:19 +0000
@@ -90,6 +90,8 @@
 #define ZED_ZDST0027_NON_ORDERED_KEY_TYPE "~ZDST0027_NON_ORDERED_KEY_TYPE"
 #define ZED_ZDST0060_unknown_namespace "~ZDST0060_unknown_namespace"
 #define ZED_ZDST0060_unknown_localname "~ZDST0060_unknown_localname"
+#define ZED_ZSTR0060_ForCollection_3 "~ZSTR0060_ForCollection_3"
+#define ZED_ZSTR0060_ForSequence "~ZSTR0060_ForSequence"
 #define ZED_JNUP0007_Object "~JNUP0007_Object"
 #define ZED_JNUP0007_Array "~JNUP0007_Array"
 #define ZED_JNUP0007_ObjectArray "~JNUP0007_ObjectArray"

=== modified file 'src/store/naive/json_items.cpp'
--- src/store/naive/json_items.cpp	2013-01-08 05:02:54 +0000
+++ src/store/naive/json_items.cpp	2013-02-03 19:03:19 +0000
@@ -1014,10 +1014,12 @@
   {
     return to_xs_unsignedLong(i);
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
-    throw ZORBA_EXCEPTION(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("access out of bounds " << e.what() << ")")));
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( i )
+    );
   }
 }
 

=== modified file 'src/store/naive/pul_primitives.cpp'
--- src/store/naive/pul_primitives.cpp	2013-01-22 11:07:53 +0000
+++ src/store/naive/pul_primitives.cpp	2013-02-03 19:03:19 +0000
@@ -1024,11 +1024,15 @@
   {
     size = to_xs_unsignedLong(collection->size());
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
     RAISE_ERROR(zerr::ZSTR0060_RANGE_EXCEPTION, theLoc,
-    ERROR_PARAMS(BUILD_STRING("collection too big ("
-                              << e.what() << "; " << theName << ")")));
+      ERROR_PARAMS(
+        collection->size(),
+        ZED( ZSTR0060_ForCollection_3 ),
+        theName
+      )
+    );
   }
 
   for (uint64_t i = 0; i < size; ++i)
@@ -1101,11 +1105,15 @@
   {
     lastPos = to_xs_unsignedLong(lColl->size()) - 1;
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
     RAISE_ERROR(zerr::ZSTR0060_RANGE_EXCEPTION, theLoc,
-    ERROR_PARAMS(BUILD_STRING("collection too big ("
-                              << e.what() << "; " << theName << ")")));
+      ERROR_PARAMS(
+        lColl->size(),
+        ZED( ZSTR0060_ForCollection_3 ),
+        theName
+      )
+    );
   }
 
   for (long i = theNumApplied-1; i >= 0; --i)
@@ -1192,11 +1200,15 @@
   {
     lastPos = to_xs_unsignedLong(lColl->size()) - 1;
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
     RAISE_ERROR(zerr::ZSTR0060_RANGE_EXCEPTION, theLoc,
-    ERROR_PARAMS(BUILD_STRING("collection too big ("
-                              << e.what() << "; " << theName << ")")));
+      ERROR_PARAMS(
+        lColl->size(),
+        ZED( ZSTR0060_ForCollection_3 ),
+        theName
+      )
+    );
   }
 
   xs_integer const xs_lastPos( lastPos );
@@ -1291,11 +1303,15 @@
   {
     size = to_xs_unsignedLong(coll->size());
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
     RAISE_ERROR(zerr::ZSTR0060_RANGE_EXCEPTION, theLoc,
-    ERROR_PARAMS(BUILD_STRING("collection too big ("
-                              << e.what() << "; " << theName << ")")));
+      ERROR_PARAMS(
+        coll->size(),
+        ZED( ZSTR0060_ForCollection_3 ),
+        theName
+      )
+    );
   }
 
   csize numNodes = theNodes.size();

=== modified file 'src/store/naive/simple_lazy_temp_seq.cpp'
--- src/store/naive/simple_lazy_temp_seq.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_lazy_temp_seq.cpp	2013-02-03 19:03:19 +0000
@@ -16,9 +16,11 @@
 #include "stdafx.h"
 #include <limits>
 
-#include "diagnostics/xquery_exception.h"
+#include <zorba/diagnostic_list.h>
 #include "diagnostics/assert.h"
+#include "diagnostics/dict.h"
 #include "diagnostics/util_macros.h"
+#include "diagnostics/xquery_exception.h"
 
 #include "store/api/item.h"
 #include "simple_lazy_temp_seq.h"
@@ -170,10 +172,10 @@
   {
     pos = to_xs_long(position);
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
     throw ZORBA_EXCEPTION(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("sequence too big (" << e.what() << ")")));
+    ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence)));
   }
 
   ZORBA_ASSERT(pos >= thePurgedUpTo);
@@ -202,10 +204,10 @@
   {
     pos = to_xs_long(position);
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
     RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("access out of bounds " << e.what() << ")")));
+    ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence)));
   }
 
   ZORBA_ASSERT(pos > thePurgedUpTo);
@@ -255,10 +257,10 @@
   {
     pos = to_xs_long(position);
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
     RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("access out of bounds " << e.what() << ")")));
+    ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence)));
   }
 
   ZORBA_ASSERT(pos > thePurgedUpTo);
@@ -317,17 +319,26 @@
   :
   theTempSeq(const_cast<SimpleLazyTempSeq*>(tempSeq))
 {
-  try 
-  {
+  try {
     theStartPos = to_xs_long(startPos);
+  }
+  catch ( std::range_error const& ) {
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( startPos, ZED( ZSTR0060_ForSequence ) )
+    );
+  }
+  try {
     theEndPos = to_xs_long(endPos);
-    theCurPos = theStartPos - 1;
-  }
-  catch (std::range_error& e)
-  {
-    RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("sequence too big (" << e.what() << ")")));
-  }
+  }
+  catch ( std::range_error const& ) {
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( endPos, ZED( ZSTR0060_ForSequence ) )
+    );
+  }
+
+  theCurPos = theStartPos - 1;
 }
 
 
@@ -360,17 +371,26 @@
 
   theTempSeq = static_cast<SimpleLazyTempSeq*>(seq.getp());
 
-  try 
-  {
+  try {
     theStartPos = to_xs_long(startPos);
+  }
+  catch ( std::range_error const& ) {
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( startPos, ZED( ZSTR0060_ForSequence ) )
+    );
+  }
+  try {
     theEndPos = to_xs_long(endPos);
-    theCurPos = theStartPos - 1;
-  }
-  catch (std::range_error& e)
-  {
-    RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("sequence too big (" << e.what() << ")")));
-  }
+  }
+  catch ( std::range_error const& ) {
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( endPos, ZED( ZSTR0060_ForSequence ) )
+    );
+  }
+
+  theCurPos = theStartPos - 1;
 }
 
 

=== modified file 'src/store/naive/simple_temp_seq.cpp'
--- src/store/naive/simple_temp_seq.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_temp_seq.cpp	2013-02-03 19:03:19 +0000
@@ -15,10 +15,11 @@
  */
 #include "stdafx.h"
 
-#include "diagnostics/xquery_exception.h"
-#include "zorba/diagnostic_list.h"
+#include <zorba/diagnostic_list.h>
 #include "diagnostics/diagnostic.h"
+#include "diagnostics/dict.h"
 #include "diagnostics/util_macros.h"
+#include "diagnostics/zorba_exception.h"
 
 #include "store/api/item.h"
 #include "simple_temp_seq.h"
@@ -167,10 +168,12 @@
   {
     pos = to_xs_long(position);
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
-    RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("access out of bounds " << e.what() << ")")));
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( position, ZED(ZSTR0060_ForSequence) )
+    );
   }
 
   if (0 < pos && pos <= theItems.size())
@@ -194,10 +197,12 @@
   {
     pos = to_xs_long(position);
   }
-  catch (std::range_error& e)
+  catch (std::range_error const&)
   {
-    RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("access out of bounds " << e.what() << ")")));
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( position, ZED(ZSTR0060_ForSequence) )
+    );
   }
 
   return 0 < pos && pos <= theItems.size();
@@ -260,15 +265,23 @@
   xs_long start;
   xs_long end;
 
-  try 
-  {
+  try {
     start = to_xs_long(startPos);
+  }
+  catch ( std::range_error const& ) {
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( start, ZED(ZSTR0060_ForSequence) )
+    );
+  }
+  try {
     end = to_xs_long(endPos);
   }
-  catch (std::range_error& e)
-  {
-    RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
-    ERROR_PARAMS(BUILD_STRING("access out of bounds " << e.what() << ")")));
+  catch ( std::range_error const& ) {
+    throw ZORBA_EXCEPTION(
+      zerr::ZSTR0060_RANGE_EXCEPTION,
+      ERROR_PARAMS( end, ZED(ZSTR0060_ForSequence) )
+    );
   }
 
   if (start > 0 && end > 0)

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to