bt2: reverse order of printed causes in _Error.__str__
[babeltrace.git] / src / bindings / python / bt2 / bt2 / error.py
index dc1e65f55fb03b91e5f2af426468364bac05025c..a50827a85b3889d3c86b4fb780d20df4d20b0c0a 100644 (file)
@@ -162,12 +162,14 @@ class _Error(Exception, abc.Sequence):
     the ERROR or MEMORY_ERROR status codes.
     """
 
-    def __init__(self, msg, ptr=None):
+    def __init__(self, msg):
         super().__init__(msg)
         # Steal the current thread's error.
         self._ptr = native_bt.current_thread_take_error()
         assert self._ptr is not None
 
+        self._msg = msg
+
         # Read everything we might need from the error pointer, so we don't
         # depend on it.  It's possible for the user to keep an Error object
         # and to want to read its causes after the error pointer has been
@@ -208,3 +210,9 @@ class _Error(Exception, abc.Sequence):
 
     def __len__(self):
         return len(self._causes)
+
+    def __str__(self):
+        s = self._msg + '\n'
+        for c in reversed(self):
+            s += str(c) + '\n'
+        return s
This page took 0.026981 seconds and 4 git commands to generate.