diff --git a/resources/lib/helper/__init__.py b/resources/lib/helper/__init__.py index 2612826f..beb06035 100644 --- a/resources/lib/helper/__init__.py +++ b/resources/lib/helper/__init__.py @@ -19,6 +19,7 @@ from utils import create_id from wrapper import progress from wrapper import catch +from wrapper import silent_catch from wrapper import stop from wrapper import emby_item from wrapper import library_check diff --git a/resources/lib/helper/wrapper.py b/resources/lib/helper/wrapper.py index 20bd3bcf..e0acc176 100644 --- a/resources/lib/helper/wrapper.py +++ b/resources/lib/helper/wrapper.py @@ -61,6 +61,21 @@ def catch(errors=(Exception,)): return wrapper return decorator +def silent_catch(errors=(Exception,)): + + ''' Wrapper to catch exceptions and ignore them + ''' + def decorator(func): + def wrapper(*args, **kwargs): + + try: + return func(*args, **kwargs) + except errors as error: + LOG.error(error) + + return wrapper + return decorator + def stop(default=None): ''' Wrapper to catch exceptions and return using catch