Create the ProxyError Exception. Raise it when an unproxy
authorNathan Binkert <binkertn@umich.edu>
Mon, 19 Dec 2005 07:07:06 +0000 (02:07 -0500)
committerNathan Binkert <binkertn@umich.edu>
Mon, 19 Dec 2005 07:07:06 +0000 (02:07 -0500)
operation fails because information is wrong or not available.

--HG--
extra : convert_revision : 1fd90c1291618b09752179cfa6894f1df495fffd

util/stats/info.py

index 1f9f11940fb5d34e5998679846f6b64bbc022856..4cb55f564d21d5e1fde6d59e49606a277cad02f5 100644 (file)
@@ -27,6 +27,9 @@
 from __future__ import division
 import operator, re, types
 
+class ProxyError(Exception):
+    pass
+
 def unproxy(proxy):
     if hasattr(proxy, '__unproxy__'):
         return proxy.__unproxy__()
@@ -336,7 +339,12 @@ class AttrProxy(Proxy):
         self.attr = attr
 
     def __unproxy__(self):
-        return unproxy(getattr(unproxy(self.proxy), self.attr))
+        proxy = unproxy(self.proxy)
+        try:
+            attr = getattr(proxy, self.attr)
+        except AttributeError, e:
+            raise ProxyError, e
+        return unproxy(attr)
 
     def __str__(self):
         return '%s.%s' % (self.proxy, self.attr)