[Swift-commit] r5564 - trunk/src/org/griphyn/vdl/karajan/lib/swiftscript

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Wed Feb 8 08:22:29 CST 2012


Author: davidk
Date: 2012-02-08 08:22:28 -0600 (Wed, 08 Feb 2012)
New Revision: 5564

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
Log:
Give more detail for tracef/sprintf type mismatch errors


Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java	2012-02-08 03:18:57 UTC (rev 5563)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java	2012-02-08 14:22:28 UTC (rev 5564)
@@ -189,7 +189,7 @@
         }
         else {
             throw new ExecutionException
-            ("tracef(): %b requires a boolean!");
+            ("tracef(): %b requires a boolean! " + dshandleDescription(arg));
         }
     }
     
@@ -200,7 +200,7 @@
         }
         else {
             throw new ExecutionException
-            ("tracef(): %f requires a float!");
+            ("tracef(): %f requires a float! " + dshandleDescription(arg));
         }
     }
 
@@ -212,7 +212,7 @@
         }
         else {
             throw new ExecutionException
-            ("tracef(): %i requires an int!");
+            ("tracef(): %i requires an int! " + dshandleDescription(arg));
         }
     }
     
@@ -241,7 +241,7 @@
         }
         else {
             throw new ExecutionException
-            ("tracef(): %q requires an array!");
+            ("tracef(): %q requires an array! " + dshandleDescription(arg));
         }        
     }
     
@@ -252,7 +252,7 @@
         }
         else {
             throw new ExecutionException
-            ("tracef(): %s requires a string!");
+            ("tracef(): %s requires a string! " + dshandleDescription(arg));
         }
     }
     
@@ -279,4 +279,12 @@
             		    "\t in " + spec + " character: " + i);
         }
     }
+    
+    /**
+     * Return String containing variable name and type of a given DSHandle
+     */
+    private static String dshandleDescription(DSHandle dshandle) {
+        String variableName = (dshandle.getRoot().toString().split(":")[0]);
+        return "Variable \"" + variableName + "\" is a " + dshandle.getType();
+    }
 }




More information about the Swift-commit mailing list