def error_handler(exception): """ This function is called each time run() trigger an Exception """ params = entrypoint_utils.get_params_in_query(sys.argv[2]) # If it's an HTTPError if isinstance(exception, urlquick.HTTPError): code = exception.code msg = exception.msg # hdrs = exception.hdrs # url = exception.filename Script.log( 'urlquick.get() failed with HTTPError code {} with message "{}"'. format(code, msg, lvl=Script.ERROR)) # Build dialog message dialog_message = msg if 'http_code_' + str(code) in LABELS: dialog_message = Script.localize(LABELS['http_code_' + str(code)]) # Build dialog title dialog_title = Script.localize( LABELS['HTTP Error code']) + ' ' + str(code) # Show xbmc dialog xbmcgui.Dialog().ok(dialog_title, dialog_message) # If error code is in avoid_log_uploader, then return # Else, let log_uploader run avoid_log_uploader = [403, 404] if code in avoid_log_uploader: return # If we come from fav menu we # suggest user to delete this item if 'from_fav' in params: fav.ask_to_delete_error_fav_item(params) # Else, we ask the user if he wants # to share his log to addon devs elif Script.setting.get_boolean('log_pop_up'): ask_to_share_log = True log_exceptions = [ 'No items found', 'Youtube-DL: Video geo-restricted by the owner' ] for log_exception in log_exceptions: if log_exception in str(exception): ask_to_share_log = False if ask_to_share_log: log_uploader = importlib.import_module( 'resources.lib.log_uploader') log_uploader.ask_to_share_log()
def error_handler(exception): """ This function is called each time run() trigger an Exception """ params = cqu.get_params_in_query(sys.argv[2]) # If we come from fav menu we # suggest user to delete this item if 'from_fav' in params: fav.ask_to_delete_error_fav_item(params) # Else, we ask the user if he wants # to share his log to addon devs else: log_uploader = importlib.import_module('resources.lib.log_uploader') log_uploader.ask_to_share_log()
def error_handler(exception): """Callback function called when the run() triggers an error Args: exception (Exception) """ # Parameters found in Kodi URL during this error params = get_params_in_query(sys.argv[2]) # If it's an HTTPError if isinstance(exception, urlquick.HTTPError): code = exception.code msg = exception.msg # hdrs = exception.hdrs # url = exception.filename Script.log('urlquick.get() failed with HTTPError code {} with message "{}"'.format(code, msg, lvl=Script.ERROR)) # Build dialog message dialog_message = msg http_code_msg = { 500: 30891, 401: 30892, 403: 30893, 402: 30894, 404: 30895 } if code in http_code_msg: dialog_message = Script.localize(http_code_msg[code]) # Build dialog title dialog_title = Script.localize(30890) + ' ' + str(code) # Show xbmc dialog xbmcgui.Dialog().ok(dialog_title, dialog_message) # If error code is in avoid_log_uploader, then return # Else, let log_uploader run avoid_log_uploader = [403, 404] if code in avoid_log_uploader: return # If we come from fav menu we # suggest user to delete this item if 'from_fav' in params: fav.ask_to_delete_error_fav_item(params['item_hash']) # Else, we ask the user if he wants # to share his log to addon devs elif Script.setting.get_boolean('log_pop_up'): ask_to_share_log = True log_exceptions = ['No items found', 'Youtube-DL: Video geo-restricted by the owner'] for log_exception in log_exceptions: if log_exception in str(exception): ask_to_share_log = False if ask_to_share_log: log_uploader = importlib.import_module('resources.lib.log_uploader') log_uploader.ask_to_share_log()
# Build dialog title dialog_title = Script.localize(30890) + ' ' + str(code) # Show xbmc dialog xbmcgui.Dialog().ok(dialog_title, dialog_message) # If error code is in avoid_log_uploader, then return # Else, let log_uploader run avoid_log_uploader = [403, 404] if code in avoid_log_uploader: return # If we come from fav menu we # suggest user to delete this item if 'from_fav' in params: fav.ask_to_delete_error_fav_item(params['item_hash']) # Else, we ask the user if he wants # to share his log to addon devs elif Script.setting.get_boolean('log_pop_up'): ask_to_share_log = True log_exceptions = ['No items found', 'Youtube-DL: Video geo-restricted by the owner'] for log_exception in log_exceptions: if log_exception in str(exception): ask_to_share_log = False if ask_to_share_log: log_uploader = importlib.import_module('resources.lib.log_uploader') log_uploader.ask_to_share_log()