More descriptive exception messages for design errors
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Thu, 19 May 2011 16:05:33 +0000 (18:05 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Thu, 19 May 2011 16:05:33 +0000 (18:05 +0200)
src/nepi/core/connector.py
src/nepi/core/design.py

index 7cd415f..e85d2bf 100644 (file)
@@ -28,6 +28,9 @@ class ConnectorTypeBase(object):
         # min -- minimum amount of connections required by this type of connector
         self._min = min
 
+    def __str__(self):
+        return "ConnectorType%r" % (self._connector_type_id,)
+
     @property
     def connector_type_id(self):
         return self._connector_type_id
index f89c094..50a8133 100644 (file)
@@ -53,6 +53,9 @@ class Connector(object):
         self._connector_type = connector_type
         self._connections = list()
 
+    def __str__(self):
+        return "Connector(%s, %s)" % (self.box, self.connector_type)
+
     @property
     def box(self):
         return self._box
@@ -80,7 +83,7 @@ class Connector(object):
 
     def connect(self, connector):
         if not self.can_connect(connector) or not connector.can_connect(self):
-            raise RuntimeError("Could not connect.")
+            raise RuntimeError("Could not connect. %s to %s" % (self, connector))
         self._connections.append(connector)
         connector._connections.append(self)
 
@@ -202,6 +205,9 @@ class Box(AttributesMap):
             if attr.modified:
                 self._factory_attributes[attr.name] = attr.value
 
+    def __str__(self):
+        return "Box(%s, %s, %s)" % (self.guid, self.factory_id, self.testbed_guid)
+
     @property
     def guid(self):
         return self._guid