Till Westmann has proposed merging lp:~zorba-coders/zorba/bug-1009366 into 
lp:zorba.

Requested reviews:
  Chris Hillery (ceejatec)
  Markos Zaharioudakis (markos-za)
Related bugs:
  Bug #1009366 in Zorba: "access denied error message for module URIs does not 
contain location information"
  https://bugs.launchpad.net/zorba/+bug/1009366

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1009366/+merge/108894

add location information to ZXQP0029_URI_ACCESS_DENIED
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1009366/+merge/108894
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-05-09 23:06:41 +0000
+++ src/compiler/translator/translator.cpp	2012-06-06 08:01:24 +0000
@@ -2955,13 +2955,24 @@
       // rather than using compURI directly, because we want the version
       // fragment to be passed to the mappers.
       zstring lErrorMessage;
-      std::auto_ptr<internal::Resource> lResource =
-      theSctx->resolve_uri(compModVer.versioned_uri(),
-                           internal::EntityData::MODULE,
-                           lErrorMessage);
-
-      internal::StreamResource* lStreamResource =
-      dynamic_cast<internal::StreamResource*> (lResource.get());
+      std::auto_ptr<internal::Resource> lResource;
+      internal::StreamResource* lStreamResource = NULL;
+
+      try
+      {
+        lResource =
+        theSctx->resolve_uri(compModVer.versioned_uri(),
+                             internal::EntityData::MODULE,
+                             lErrorMessage);
+
+        lStreamResource =
+        dynamic_cast<internal::StreamResource*> (lResource.get());
+      }
+      catch (XQueryException& e)
+      {
+        set_source(e, loc);
+        throw;
+      }
 
       if (lStreamResource != NULL)
       {

=== modified file 'test/api/userdefined_uri_resolution.cpp'
--- test/api/userdefined_uri_resolution.cpp	2012-05-05 02:39:12 +0000
+++ test/api/userdefined_uri_resolution.cpp	2012-06-06 08:01:24 +0000
@@ -21,6 +21,7 @@
 #include <zorba/zorba.h>
 #include <zorba/store_manager.h>
 #include <zorba/zorba_exception.h>
+#include <zorba/xquery_exception.h>
 #include <zorba/uri_resolvers.h>
 #include <zorba/diagnostic_list.h>
 
@@ -297,12 +298,15 @@
         "'http://expath.org/ns/file'; "
         "1 + 1", lContext);
     std::cout << lQuery << std::endl;
-  } catch (ZorbaException& e) {
+  } catch (XQueryException& e) {
     std::cout << "Caught exception: " << e.what() << std::endl;
-    if (e.diagnostic() == zerr::ZXQP0029_URI_ACCESS_DENIED) {
-      std::cout << "...the correct exception!" << std::endl;
+    if (e.diagnostic() == zerr::ZXQP0029_URI_ACCESS_DENIED
+        && e.has_source()
+        && e.source_line() == 1) {
       return true;
     }
+  } catch (ZorbaException& e) {
+    std::cout << "Caught unexpected exception: " << e.what() << std::endl;
   }
   return false;
 }

-- 
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