Move catch except to _common.py

This commit is contained in:
angelblue05 2016-10-27 22:31:58 -05:00
parent 3630f52c07
commit 090ff79e8f
5 changed files with 23 additions and 8 deletions

View file

@ -20,6 +20,21 @@ log = logging.getLogger("EMBY."+__name__)
##################################################################################################
def catch_except(errors=(Exception, ), default_value=False):
# Will wrap method with try/except and print parameters for easier debugging
def decorator(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except errors as error:
log.exception(error)
log.error("function: %s \n args: %s \n kwargs: %s",
func.__name__, args, kwargs)
return default_value
return wrapper
return decorator
class Items(object):

View file

@ -8,8 +8,8 @@ import urllib
import api
import embydb_functions as embydb
import _kodi_movies
from _common import Items
from utils import window, settings, language as lang, catch_except
from _common import Items, catch_except
from utils import window, settings, language as lang
##################################################################################################

View file

@ -9,8 +9,8 @@ import api
import embydb_functions as embydb
import musicutils
import _kodi_music
from _common import Items
from utils import window, settings, language as lang, catch_except
from _common import Items, catch_except
from utils import window, settings, language as lang
##################################################################################################

View file

@ -8,8 +8,8 @@ import urllib
import api
import embydb_functions as embydb
import _kodi_musicvideos
from _common import Items
from utils import window, settings, language as lang, catch_except
from _common import Items, catch_except
from utils import window, settings, language as lang
##################################################################################################

View file

@ -9,8 +9,8 @@ from ntpath import dirname
import api
import embydb_functions as embydb
import _kodi_tvshows
from _common import Items
from utils import window, settings, language as lang, catch_except
from _common import Items, catch_except
from utils import window, settings, language as lang
##################################################################################################