Completed
Push — master ( 316d56...86da25 )
by Olivier
01:02
created

trycatch()   A

Complexity

Conditions 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
c 1
b 0
f 1
dl 0
loc 13
rs 9.4285
1
2
import inspect
3
import logging
4
5
6
logger = logging.getLogger(__name__)
7
8
9
def trycatch(func):
10
    def wrapper(self, *args):
11
        # filter out excess args as qt signals do
12
        sig = inspect.signature(func)
13
        args = args[:(len(sig.parameters)-1)]
14
        result = None
15
        try:
16
            result = func(self, *args)
17
        except Exception as ex:
18
            logger.exception(ex)
19
            self.error.emit(ex)
20
        return result
21
    return wrapper
22
23
24