← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1009366 into lp:zorba

 

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

Requested reviews:
  Markos Zaharioudakis (markos-za)
  Chris Hillery (ceejatec)
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/110410

add location information to ZXQP0029_URI_ACCESS_DENIED
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1009366/+merge/110410
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-06-14 15:20:15 +0000
+++ src/compiler/translator/translator.cpp	2012-06-14 20:36:35 +0000
@@ -2967,13 +2967,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 (ZorbaException& e)
+      {
+        set_source(e, loc);
+        throw;
+      }
 
       if (lStreamResource != NULL)
       {

=== modified file 'test/api/userdefined_uri_resolution.cpp'
--- test/api/userdefined_uri_resolution.cpp	2012-06-14 15:20:15 +0000
+++ test/api/userdefined_uri_resolution.cpp	2012-06-14 20:36:35 +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,16 @@
         "'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) {
+    if (e.diagnostic() == zerr::ZXQP0029_URI_ACCESS_DENIED
+        && e.has_source()
+        && e.source_line() == 1) {
       std::cout << "...the correct exception!" << std::endl;
       return true;
     }
+  } catch (ZorbaException& e) {
+    std::cout << "Caught unexpected exception: " << e.what() << std::endl;
   }
   return false;
 }


Follow ups