[Swift-commit] r6645 - in trunk/src/org/griphyn/vdl: karajan/lib mapping

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri Jul 12 23:16:24 CDT 2013


Author: hategan
Date: 2013-07-12 23:16:23 -0500 (Fri, 12 Jul 2013)
New Revision: 6645

Added:
   trunk/src/org/griphyn/vdl/mapping/NotCompositeException.java
Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/New.java
   trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
   trunk/src/org/griphyn/vdl/mapping/RootDataNode.java
Log:
better error message when mapping multiple files to a non-composite type

Modified: trunk/src/org/griphyn/vdl/karajan/lib/New.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/New.java	2013-07-13 01:36:13 UTC (rev 6644)
+++ trunk/src/org/griphyn/vdl/karajan/lib/New.java	2013-07-13 04:16:23 UTC (rev 6645)
@@ -257,4 +257,9 @@
             sb.append(v);
         }
     }
+
+    @Override
+    public String getTextualName() {
+        return "Variable declaration";
+    }
 }

Modified: trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2013-07-13 01:36:13 UTC (rev 6644)
+++ trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2013-07-13 04:16:23 UTC (rev 6645)
@@ -346,6 +346,10 @@
             throw new RuntimeException("Cannot write to closed handle: " + this + " (" + key + ")");
         }
         
+        if (!getType().isComposite()) {
+            throw new NotCompositeException(this);
+        }
+        
         return addHandle(key, newNode(getChildField(key)));
     }
     

Added: trunk/src/org/griphyn/vdl/mapping/NotCompositeException.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/NotCompositeException.java	                        (rev 0)
+++ trunk/src/org/griphyn/vdl/mapping/NotCompositeException.java	2013-07-13 04:16:23 UTC (rev 6645)
@@ -0,0 +1,27 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 12, 2013
+ */
+package org.griphyn.vdl.mapping;
+
+public class NotCompositeException extends RuntimeException {
+    private AbstractDataNode node;
+
+    public NotCompositeException(AbstractDataNode node) {
+        this.node = node;
+    }
+
+    @Override
+    public String getMessage() {
+        return "Type '" + node.getType() + "' is not a composite type.";
+    }
+    
+    public AbstractDataNode getDataNode() {
+        return node;
+    }
+}

Modified: trunk/src/org/griphyn/vdl/mapping/RootDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/RootDataNode.java	2013-07-13 01:36:13 UTC (rev 6644)
+++ trunk/src/org/griphyn/vdl/mapping/RootDataNode.java	2013-07-13 04:16:23 UTC (rev 6645)
@@ -184,6 +184,11 @@
                 throw new IllegalStateException("Structure of mapped data is " +
                         "incompatible with the mapped variable type: " + e.getMessage());
             }
+            catch (NotCompositeException e) {
+                throw new IllegalStateException("Cannot map multiple files to variable '" + 
+                    e.getDataNode().getFullName() + "' of non composite type '" + 
+                    e.getDataNode().getType() + "'");
+            }
         }
         root.closeDeep();
         if (!any && tracer.isEnabled()) {




More information about the Swift-commit mailing list