X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bindings%2Fpython%2Fbt2%2Fbt2%2Futils.py;h=0c59a4d7aa973ed0e464423a9bc67a0a7a2abf95;hb=447c0da9f0bc618ca053feded4f3028ffe6cb35b;hp=294fadb6edc91a4bc1952dab96f8f08545ed50ed;hpb=39211d0e538fe9167497198038ebd8cc1dfc5a6d;p=babeltrace.git diff --git a/bindings/python/bt2/bt2/utils.py b/bindings/python/bt2/bt2/utils.py index 294fadb6..0c59a4d7 100644 --- a/bindings/python/bt2/bt2/utils.py +++ b/bindings/python/bt2/bt2/utils.py @@ -92,21 +92,17 @@ def _check_alignment(a): raise ValueError('{} is not a power of two'.format(a)) +def _raise_bt2_error(msg): + if msg is None: + raise bt2.Error + else: + raise bt2.Error(msg) + def _handle_ret(ret, msg=None): if int(ret) < 0: - if msg is None: - error = bt2.Error() - else: - error = bt2.Error(msg) - - raise error + _raise_bt2_error(msg) def _handle_ptr(ptr, msg=None): if ptr is None: - if msg is None: - error = bt2.Error() - else: - error = bt2.Error(msg) - - raise error + _raise_bt2_error(msg)