bt2: remove ptr parameter of _Error.__init__
[babeltrace.git] / src / bindings / python / bt2 / bt2 / error.py
index 7fd4648246d34685232c52385fc63fdbafe2c9ef..4e3e53f0314f7a7c5331d97cec45374ed3f48f46 100644 (file)
@@ -1,4 +1,4 @@
-from bt2 import utils, native_bt
+from bt2 import native_bt
 from collections import abc
 
 
@@ -154,7 +154,7 @@ _ACTOR_TYPE_TO_CLS = {
 }
 
 
-class Error(Exception, abc.Sequence):
+class _Error(Exception, abc.Sequence):
     """
     Babeltrace API call error.
 
@@ -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 self:
+            s += str(c) + '\n'
+        return s
This page took 0.023714 seconds and 4 git commands to generate.