#2495 Compiler swallows Err msgs

SlimerDude Tue 17 Nov 2015

Just to say it was quick tricky to track down the little problem in the last topic, mainly because compiler kept swallowing error messages and the context of the original problem.

For example, all compiler would report for the last issue was:

Cannot resolve depend: pod 'afPlastic'

Which clearly was not the case, as I could quite obviously see my resolved pod file!

Here are some compiler tweaks that let the original err msg pass though:

diff -r 7194bb092a91 src/compiler/fan/namespace/CNamespace.fan
--- a/src/compiler/fan/namespace/CNamespace.fan	Fri Nov 06 14:03:10 2015 -0500
+++ b/src/compiler/fan/namespace/CNamespace.fan	Tue Nov 17 23:39:50 2015 +0000
@@ -225,7 +225,16 @@
     else
     {
       // let namespace resolve it
-      pod = findPod(podName)
+      try
+      {
+        pod = findPod(podName)
+      }
+      catch (Err e)
+      {
+        msg := "Pod not found '$podName'" + (e.msg == podName ? "" : " - ${e.msg}")
+        throw CompilerErr(msg, loc)
+      }
+      
       if (pod == null)
         throw CompilerErr("Pod not found '$podName'", loc)
     }
diff -r 7194bb092a91 src/compiler/fan/namespace/ReflectNamespace.fan
--- a/src/compiler/fan/namespace/ReflectNamespace.fan	Fri Nov 06 14:03:10 2015 -0500
+++ b/src/compiler/fan/namespace/ReflectNamespace.fan	Tue Nov 17 23:39:50 2015 +0000
@@ -37,7 +37,7 @@
   protected override ReflectPod? findPod(Str podName)
   {
     // try to load it
-    pod := Pod.find(podName, false)
+    pod := Pod.find(podName, true)
     if (pod == null) return null
     return ReflectPod(this, pod)
   }
diff -r 7194bb092a91 src/compiler/fan/steps/InitInput.fan
--- a/src/compiler/fan/steps/InitInput.fan	Fri Nov 06 14:03:10 2015 -0500
+++ b/src/compiler/fan/steps/InitInput.fan	Tue Nov 17 23:39:50 2015 +0000
@@ -176,7 +176,7 @@
     uris?.each |uri|
     {
       f := base + uri
-      if (!f.exists) throw err("Invalid file or directory", Loc.makeFile(f))
+      if (!f.exists) throw err("Invalid file or directory: ${f.normalize.osPath}", Loc.makeFile(f))
       if (f.isDir)
       {
         f.list.each |kid|
diff -r 7194bb092a91 src/compiler/fan/steps/ResolveDepends.fan
--- a/src/compiler/fan/steps/ResolveDepends.fan	Fri Nov 06 14:03:10 2015 -0500
+++ b/src/compiler/fan/steps/ResolveDepends.fan	Tue Nov 17 23:39:50 2015 +0000
@@ -93,7 +93,7 @@
     }
     catch (CompilerErr e)
     {
-      err("Cannot resolve depend: pod '$depend.name' not found", loc)
+      err(e.msg.trimToNull ?: "Cannot resolve depend: pod '$depend.name' not found", loc)
       return null
     } 

In the eventuality of a case mismatch, compiler now reports:

Pod not found 'afPlastic' - Case mismatch: expected 'afPlastic.pod' but found 'afPlastiC.POD'

brian Wed 18 Nov 2015

This change requires modifying the semantics of findPod to raise an error instead of returning null, which I don't really like since its sort of an rare condition - 99.9% of the time its simply that the pod isn't found. You happened to stumble upon a pretty rare case which we've already changed.

Login or Signup to reply.