mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 16:33:43 +02: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
2 changed files with 17 additions and 6 deletions
|
|
@ -33,14 +33,19 @@ def remove_initial_progress_bar():
|
|||
p.parentNode.removeChild(p)
|
||||
|
||||
def onerror(msg, script_url, line_number, column_number, error_object):
|
||||
if error_object:
|
||||
console.log(error_object)
|
||||
if error_object is None:
|
||||
# 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:
|
||||
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>'
|
||||
details = ''
|
||||
if error_object:
|
||||
details = traceback.format_exception(error_object).join('')
|
||||
details = traceback.format_exception(error_object).join('')
|
||||
error_dialog(_('Unhandled error'), msg, details)
|
||||
return True
|
||||
except:
|
||||
|
|
|
|||
|
|
@ -138,8 +138,14 @@ def print_to_parent(self, *args):
|
|||
self.send_message('print', string=' '.join(map(str, args)))
|
||||
|
||||
def onerror(self, msg, script_url, line_number, column_number, error_object):
|
||||
if error_object:
|
||||
console.log(error_object)
|
||||
if error_object is None:
|
||||
# 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:
|
||||
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>'
|
||||
|
|
|
|||
Loading…
Reference in a new issue