bt2: prepend underscore to exceptions not meant to be raised by user
[babeltrace.git] / src / bindings / python / bt2 / bt2 / trace.py
index 5ddcbad29719123404c7ffc8d09c3ce878c77b54..a90b53ce9433352d33bae6a7308f167b3088db12 100644 (file)
@@ -166,7 +166,7 @@ class _Trace(object._SharedObject, collections.abc.Mapping):
             )
 
         if stream_ptr is None:
-            raise bt2.CreationError('cannot create stream object')
+            raise bt2._MemoryError('cannot create stream object')
 
         stream = bt2.stream._Stream._create_from_ptr(stream_ptr)
 
@@ -185,8 +185,9 @@ class _Trace(object._SharedObject, collections.abc.Mapping):
             _trace_destruction_listener_from_native, listener
         )
 
-        listener_id = fn(self._ptr, listener_from_native)
-        if listener_id is None:
-            utils._raise_bt2_error('cannot add destruction listener to trace object')
+        status, listener_id = fn(self._ptr, listener_from_native)
+        utils._handle_func_status(
+            status, 'cannot add destruction listener to trace object'
+        )
 
         return bt2._ListenerHandle(listener_id, self)
This page took 0.026143 seconds and 4 git commands to generate.