Fix exception when trying to read ajax responsetext in error handler

This commit is contained in:
Kovid Goyal 2019-01-17 09:21:50 +05:30
parent ecb302fa04
commit 473bff43e3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -77,7 +77,10 @@ def ajax(path, on_complete, on_progress=None, bypass_cache=True, method='GET', q
elif event is 'abort': elif event is 'abort':
xhr.error_html = str.format(_('Failed to communicate with "{}", aborted'), xhr.request_path) xhr.error_html = str.format(_('Failed to communicate with "{}", aborted'), xhr.request_path)
else: else:
rtext = xhr.responseText or '' try:
rtext = xhr.responseText or ''
except:
rtext = ''
xhr.error_html = str.format(_('Failed to communicate with "{}", with status: [{}] {}<br><br>{}'), xhr.request_path, xhr.status, xhr.statusText, rtext[:200]) xhr.error_html = str.format(_('Failed to communicate with "{}", with status: [{}] {}<br><br>{}'), xhr.request_path, xhr.status, xhr.statusText, rtext[:200])
def progress_callback(ev): def progress_callback(ev):