diff --git a/src/pyj/book_list/main.pyj b/src/pyj/book_list/main.pyj
index e7b47ba5d7..bcae29c64d 100644
--- a/src/pyj/book_list/main.pyj
+++ b/src/pyj/book_list/main.pyj
@@ -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 + '
' + 'Error at {}:{}:{}'.format(fname, line_number, column_number or '') + ''
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:
diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj
index 55f0cdce4a..37476b107d 100644
--- a/src/pyj/read_book/iframe.pyj
+++ b/src/pyj/read_book/iframe.pyj
@@ -138,8 +138,14 @@ class IframeBoss:
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 + '
' + 'Error at {}:{}:{}'.format(fname, line_number, column_number or '') + ''