From 085e243e860f17c96ae3e0e723ebd6af2286fcbd Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 8 Nov 2018 17:53:36 -0600 Subject: [PATCH] Add silent catch for errors --- resources/lib/helper/__init__.py | 1 + resources/lib/helper/wrapper.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) 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