mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use the new traceback module for nicer tracebacks
This commit is contained in:
parent
36ea076b8b
commit
79802faaa2
@ -1,6 +1,7 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
import traceback
|
||||||
from ajax import ajax
|
from ajax import ajax
|
||||||
from book_list.globals import get_current_query
|
from book_list.globals import get_current_query
|
||||||
from book_list.theme import get_font_size
|
from book_list.theme import get_font_size
|
||||||
@ -241,10 +242,9 @@ def render_metadata(mi, interface_data, table, field_list=None):
|
|||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
process_field(field, fm)
|
process_field(field, fm)
|
||||||
except Exception as err:
|
except Exception:
|
||||||
print('Failed to render metadata field: ' + field)
|
print('Failed to render metadata field: ' + field)
|
||||||
print(err.toString())
|
traceback.print_exc()
|
||||||
print(err.stack)
|
|
||||||
|
|
||||||
for i, field in enumerate(sorted(comments)):
|
for i, field in enumerate(sorted(comments)):
|
||||||
comment = comments[field]
|
comment = comments[field]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
import traceback
|
||||||
from ajax import encode_query
|
from ajax import encode_query
|
||||||
from dom import set_css
|
from dom import set_css
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
@ -76,8 +77,8 @@ class Boss:
|
|||||||
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 and error_object.stack:
|
if error_object:
|
||||||
details = error_object.stack
|
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:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
import traceback
|
||||||
from book_list.globals import get_boss, get_session_data
|
from book_list.globals import get_boss, get_session_data
|
||||||
from book_list.search import SearchPanel
|
from book_list.search import SearchPanel
|
||||||
from book_list.top_bar import TopBar
|
from book_list.top_bar import TopBar
|
||||||
@ -196,7 +197,7 @@ class UI:
|
|||||||
data = JSON.parse(xhr.responseText)
|
data = JSON.parse(xhr.responseText)
|
||||||
boss.change_books(data)
|
boss.change_books(data)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return error_dialog(_('Could not change library'), err + '', details=err.stack)
|
return error_dialog(_('Could not change library'), err + '', details=traceback.format_exc())
|
||||||
self.show_panel(self.ROOT_PANEL)
|
self.show_panel(self.ROOT_PANEL)
|
||||||
window.scrollTo(0, 0)
|
window.scrollTo(0, 0)
|
||||||
elif end_type is not 'abort':
|
elif end_type is not 'abort':
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
import traceback
|
||||||
from ajax import ajax_send
|
from ajax import ajax_send
|
||||||
from dom import set_css, build_rule, clear
|
from dom import set_css, build_rule, clear
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
@ -145,8 +146,8 @@ class BooksView:
|
|||||||
raise Exception('No books ids object in search result from server')
|
raise Exception('No books ids object in search result from server')
|
||||||
self.render_ids(data.search_result.book_ids)
|
self.render_ids(data.search_result.book_ids)
|
||||||
self.interface_data.search_result = data.search_result
|
self.interface_data.search_result = data.search_result
|
||||||
except Exception as err:
|
except Exception:
|
||||||
error_dialog(_('Could not get more books'), _('Server returned an invalid response'), err.stack or err.toString())
|
error_dialog(_('Could not get more books'), _('Server returned an invalid response'), traceback.format_exc())
|
||||||
elif end_type is not 'abort':
|
elif end_type is not 'abort':
|
||||||
error_dialog(_('Could not get more books'), xhr.error_html)
|
error_dialog(_('Could not get more books'), xhr.error_html)
|
||||||
|
|
||||||
@ -230,7 +231,7 @@ class BooksView:
|
|||||||
data = JSON.parse(xhr.responseText)
|
data = JSON.parse(xhr.responseText)
|
||||||
boss.change_books(data)
|
boss.change_books(data)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return error_dialog(_('Could not change sort order'), err + '', details=err.stack)
|
return error_dialog(_('Could not change sort order'), err + '', details=traceback.format_exc())
|
||||||
boss.ui.show_panel(boss.ui.ROOT_PANEL)
|
boss.ui.show_panel(boss.ui.ROOT_PANEL)
|
||||||
window.scrollTo(0, 0)
|
window.scrollTo(0, 0)
|
||||||
elif end_type is not 'abort':
|
elif end_type is not 'abort':
|
||||||
@ -251,7 +252,7 @@ class BooksView:
|
|||||||
data = JSON.parse(xhr.responseText)
|
data = JSON.parse(xhr.responseText)
|
||||||
boss.change_books(data)
|
boss.change_books(data)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return error_dialog(_('Could not change search query'), err + '', details=err.stack)
|
return error_dialog(_('Could not change search query'), err + '', details=traceback.format_exc())
|
||||||
self.update_fetching_status()
|
self.update_fetching_status()
|
||||||
ed = xhr.extra_data_for_callback
|
ed = xhr.extra_data_for_callback
|
||||||
boss.ui.show_panel(ed.panel_to_show or boss.ui.ROOT_PANEL, push_state=ed.push_state)
|
boss.ui.show_panel(ed.panel_to_show or boss.ui.ROOT_PANEL, push_state=ed.push_state)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __python__ import bound_methods
|
from __python__ import bound_methods
|
||||||
|
|
||||||
|
import traceback
|
||||||
from aes import GCM
|
from aes import GCM
|
||||||
from gettext import install
|
from gettext import install
|
||||||
from read_book.globals import set_boss, set_current_spine_item, current_layout_mode, current_spine_item
|
from read_book.globals import set_boss, set_current_spine_item, current_layout_mode, current_spine_item
|
||||||
@ -45,7 +46,7 @@ class Boss:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
console.log('Error in iframe message handler:')
|
console.log('Error in iframe message handler:')
|
||||||
console.log(e)
|
console.log(e)
|
||||||
self.send_message('error', details=e.stack, msg=e.toString())
|
self.send_message('error', details=traceback.format_exc(), msg=e.toString())
|
||||||
else:
|
else:
|
||||||
print('Unknown action in message to iframe from parent: ' + data.action)
|
print('Unknown action in message to iframe from parent: ' + data.action)
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
# globals: __RENDER_VERSION__
|
# globals: __RENDER_VERSION__
|
||||||
|
|
||||||
|
import traceback
|
||||||
from ajax import ajax, encode_query
|
from ajax import ajax, encode_query
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
@ -138,10 +139,10 @@ class ReadUI:
|
|||||||
xhr.error_html)
|
xhr.error_html)
|
||||||
try:
|
try:
|
||||||
manifest = JSON.parse(xhr.responseText)
|
manifest = JSON.parse(xhr.responseText)
|
||||||
except Exception as err:
|
except Exception:
|
||||||
return self.show_error(_('Failed to load book manifest'),
|
return self.show_error(_('Failed to load book manifest'),
|
||||||
_('The manifest for {title} is not valid').format(title=self.current_metadata.title),
|
_('The manifest for {title} is not valid').format(title=self.current_metadata.title),
|
||||||
err.stack or err.toString())
|
traceback.format_exc())
|
||||||
if manifest.version is not RENDER_VERSION:
|
if manifest.version is not RENDER_VERSION:
|
||||||
return self.show_error(_('calibre upgraded!'), _(
|
return self.show_error(_('calibre upgraded!'), _(
|
||||||
'A newer version of calibre is available, please click the reload button in your browser.'))
|
'A newer version of calibre is available, please click the reload button in your browser.'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user