Add silent catch for errors

This commit is contained in:
angelblue05 2018-11-08 17:53:36 -06:00
parent 66367001f3
commit 085e243e86
2 changed files with 16 additions and 0 deletions

View file

@ -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

View file

@ -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