mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Do not report errors from injected javascript
Fixes continual error popups on Chrome for iOS
This commit is contained in:
parent
2fbaa19cd6
commit
622a7fcafd
@ -33,14 +33,19 @@ def remove_initial_progress_bar():
|
|||||||
p.parentNode.removeChild(p)
|
p.parentNode.removeChild(p)
|
||||||
|
|
||||||
def onerror(msg, script_url, line_number, column_number, error_object):
|
def onerror(msg, script_url, line_number, column_number, error_object):
|
||||||
if error_object:
|
if error_object is None:
|
||||||
console.log(error_object)
|
# This happens for cross-domain errors (probably javascript injected
|
||||||
|
# into the browser via extensions/ userscripts and the like). It also
|
||||||
|
# happens all the time when using Chrom on Safari, so ignore this
|
||||||
|
# type of error
|
||||||
|
console.log(f'Unhandled error from external javascript, ignoring: {msg} {script_url} {line_number}')
|
||||||
|
return
|
||||||
|
console.log(error_object)
|
||||||
try:
|
try:
|
||||||
fname = script_url.rpartition('/')[-1] or script_url
|
fname = script_url.rpartition('/')[-1] or script_url
|
||||||
msg = msg + '<br><span style="font-size:smaller">' + 'Error at {}:{}:{}'.format(fname, line_number, column_number or '') + '</span>'
|
msg = msg + '<br><span style="font-size:smaller">' + 'Error at {}:{}:{}'.format(fname, line_number, column_number or '') + '</span>'
|
||||||
details = ''
|
details = ''
|
||||||
if error_object:
|
details = traceback.format_exception(error_object).join('')
|
||||||
details = traceback.format_exception(error_object).join('')
|
|
||||||
error_dialog(_('Unhandled error'), msg, details)
|
error_dialog(_('Unhandled error'), msg, details)
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
@ -138,8 +138,14 @@ class IframeBoss:
|
|||||||
self.send_message('print', string=' '.join(map(str, args)))
|
self.send_message('print', string=' '.join(map(str, args)))
|
||||||
|
|
||||||
def onerror(self, msg, script_url, line_number, column_number, error_object):
|
def onerror(self, msg, script_url, line_number, column_number, error_object):
|
||||||
if error_object:
|
if error_object is None:
|
||||||
console.log(error_object)
|
# This happens for cross-domain errors (probably javascript injected
|
||||||
|
# into the browser via extensions/ userscripts and the like). It also
|
||||||
|
# happens all the time when using Chrom on Safari, so ignore this
|
||||||
|
# type of error
|
||||||
|
console.log(f'Unhandled error from external javascript, ignoring: {msg} {script_url} {line_number}')
|
||||||
|
return
|
||||||
|
console.log(error_object)
|
||||||
try:
|
try:
|
||||||
fname = script_url.rpartition('/')[-1] or script_url
|
fname = script_url.rpartition('/')[-1] or script_url
|
||||||
msg = msg + '<br><span style="font-size:smaller">' + 'Error at {}:{}:{}'.format(fname, line_number, column_number or '') + '</span>'
|
msg = msg + '<br><span style="font-size:smaller">' + 'Error at {}:{}:{}'.format(fname, line_number, column_number or '') + '</span>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user