diff --git a/src/pyj/book_list/boss.pyj b/src/pyj/book_list/boss.pyj
index a82b327f02..adcbfbb9f0 100644
--- a/src/pyj/book_list/boss.pyj
+++ b/src/pyj/book_list/boss.pyj
@@ -19,9 +19,13 @@ class Boss:
document.title = 'calibre :: ' + self.current_library_name
def onerror(self, msg, script_url, line_number, column_number, error_object):
- fname = str.rpartition(script_url, '/')[-1] or script_url
- msg = msg + '
' + str.format('Error at {}:{}:{}', fname, line_number, column_number or '') + ''
- details = ''
- if error_object and error_object.stack:
- details = error_object.stack
- error_dialog(_('Unhandled error'), msg, details)
+ try:
+ fname = str.rpartition(script_url, '/')[-1] or script_url
+ msg = msg + '
' + str.format('Error at {}:{}:{}', fname, line_number, column_number or '') + ''
+ details = ''
+ if error_object and error_object.stack:
+ details = error_object.stack
+ error_dialog(_('Unhandled error'), msg, details)
+ return True
+ except:
+ console.error('There was an error in the unhandled exception handler')