mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
use an exception class to surface exceptions that we dont want to log to the metrics logging system
This commit is contained in:
parent
84165e6e64
commit
aef40c4e8a
7 changed files with 35 additions and 7 deletions
|
@ -24,6 +24,7 @@ import loghandler
|
|||
from utils import window, dialog, language as lang
|
||||
from ga_client import GoogleAnalytics
|
||||
import database
|
||||
import internal_exceptions
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -161,10 +162,14 @@ if __name__ == "__main__":
|
|||
|
||||
try:
|
||||
Main()
|
||||
except internal_exceptions.ExceptionWrapper as error:
|
||||
log.exception(error)
|
||||
raise
|
||||
except Exception as error:
|
||||
ga = GoogleAnalytics()
|
||||
errStrings = ga.formatException()
|
||||
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
||||
log.exception(error)
|
||||
raise
|
||||
|
||||
log.info("plugin.video.emby stopped")
|
||||
|
|
|
@ -11,6 +11,7 @@ import xbmcgui
|
|||
import clientinfo
|
||||
import connect.connectionmanager as connectionmanager
|
||||
from utils import window, settings, language as lang
|
||||
import internal_exceptions
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -267,18 +268,18 @@ class DownloadUtils(object):
|
|||
|
||||
except requests.exceptions.SSLError as error:
|
||||
log.error("invalid SSL certificate for: %s", url)
|
||||
raise
|
||||
raise internal_exceptions.ExceptionWrapper(error)
|
||||
|
||||
except requests.exceptions.ConnectTimeout as error:
|
||||
log.error("Server timeout at: %s", url)
|
||||
raise
|
||||
raise internal_exceptions.ExceptionWrapper(error)
|
||||
|
||||
except requests.exceptions.ConnectionError as error:
|
||||
# Make the addon aware of status
|
||||
if window('emby_online') != "false":
|
||||
log.error("Server unreachable at: %s", url)
|
||||
window('emby_online', value="false")
|
||||
raise
|
||||
raise internal_exceptions.ExceptionWrapper(error)
|
||||
|
||||
except requests.exceptions.HTTPError as error:
|
||||
|
||||
|
@ -300,12 +301,12 @@ class DownloadUtils(object):
|
|||
icon=xbmcgui.NOTIFICATION_ERROR,
|
||||
time=5000)
|
||||
window('emby_serverStatus', value="restricted")
|
||||
raise Warning('restricted')
|
||||
raise internal_exceptions.ExceptionWrapper("restricted: " + str(error))
|
||||
|
||||
elif (response.headers['X-Application-Error-Code'] ==
|
||||
"UnauthorizedAccessException"):
|
||||
# User tried to do something his emby account doesn't allow
|
||||
raise Warning('UnauthorizedAccessException')
|
||||
raise internal_exceptions.ExceptionWrapper("UnauthorizedAccessException: " + str(error))
|
||||
|
||||
elif status not in ("401", "Auth"):
|
||||
# Tell userclient token has been revoked.
|
||||
|
@ -314,7 +315,7 @@ class DownloadUtils(object):
|
|||
xbmcgui.Dialog().notification(heading="Error connecting",
|
||||
message="Unauthorized.",
|
||||
icon=xbmcgui.NOTIFICATION_ERROR)
|
||||
raise Warning('401:' + str(error))
|
||||
raise internal_exceptions.ExceptionWrapper("401: " + str(error))
|
||||
|
||||
except requests.exceptions.RequestException as error:
|
||||
log.error("unknown error connecting to: %s", url)
|
||||
|
|
|
@ -8,6 +8,7 @@ import hashlib
|
|||
import xbmc
|
||||
import time
|
||||
from utils import window, settings, language as lang
|
||||
import internal_exceptions
|
||||
|
||||
log = logging.getLogger("EMBY."+__name__)
|
||||
|
||||
|
@ -22,6 +23,11 @@ def log_error(errors=(Exception, )):
|
|||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except internal_exceptions.ExceptionWrapper as error:
|
||||
log.exception(error)
|
||||
log.error("log_error: %s \n args: %s \n kwargs: %s",
|
||||
func.__name__, args, kwargs)
|
||||
raise
|
||||
except errors as error:
|
||||
ga = GoogleAnalytics()
|
||||
errStrings = ga.formatException()
|
||||
|
|
5
resources/lib/internal_exceptions.py
Normal file
5
resources/lib/internal_exceptions.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
# this is an internal exception wrapper that is used to raise exceptions
|
||||
# when you dont want them logged ot the metric logging system
|
||||
class ExceptionWrapper(Exception):
|
||||
pass
|
|
@ -24,6 +24,7 @@ import views
|
|||
from objects import Movies, MusicVideos, TVShows, Music
|
||||
from utils import window, settings, language as lang, should_stop
|
||||
from ga_client import GoogleAnalytics
|
||||
import internal_exceptions
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -618,7 +619,8 @@ class LibrarySync(threading.Thread):
|
|||
except Exception as e:
|
||||
ga = GoogleAnalytics()
|
||||
errStrings = ga.formatException()
|
||||
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
||||
if type(e) != internal_exceptions.ExceptionWrapper:
|
||||
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
||||
window('emby_dbScan', clear=True)
|
||||
log.exception(e)
|
||||
xbmcgui.Dialog().ok(
|
||||
|
|
|
@ -15,6 +15,7 @@ import downloadutils
|
|||
import read_embyserver as embyserver
|
||||
from ga_client import GoogleAnalytics
|
||||
from utils import window, settings, dialog, language as lang, should_stop
|
||||
import internal_exceptions
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -29,6 +30,9 @@ def catch_except(errors=(Exception, ), default_value=False):
|
|||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except internal_exceptions.ExceptionWrapper as error:
|
||||
log.exception(error)
|
||||
raise
|
||||
except sqlite3.Error as error:
|
||||
raise
|
||||
except errors as error:
|
||||
|
|
|
@ -22,6 +22,7 @@ import loghandler
|
|||
from service_entry import Service
|
||||
from utils import settings
|
||||
from ga_client import GoogleAnalytics
|
||||
import internal_exceptions
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -41,6 +42,10 @@ if __name__ == "__main__":
|
|||
raise RuntimeError("Abort event while waiting to start Emby for kodi")
|
||||
# Start the service
|
||||
service.service_entry_point()
|
||||
except internal_exceptions.ExceptionWrapper as error:
|
||||
log.exception(error)
|
||||
log.info("Forcing shutdown")
|
||||
service.shutdown()
|
||||
except Exception as error:
|
||||
ga = GoogleAnalytics()
|
||||
errStrings = ga.formatException()
|
||||
|
|
Loading…
Reference in a new issue