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
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import traceback
|
||||
from ajax import ajax
|
||||
from book_list.globals import get_current_query
|
||||
from book_list.theme import get_font_size
|
||||
@ -241,10 +242,9 @@ def render_metadata(mi, interface_data, table, field_list=None):
|
||||
continue
|
||||
try:
|
||||
process_field(field, fm)
|
||||
except Exception as err:
|
||||
except Exception:
|
||||
print('Failed to render metadata field: ' + field)
|
||||
print(err.toString())
|
||||
print(err.stack)
|
||||
traceback.print_exc()
|
||||
|
||||
for i, field in enumerate(sorted(comments)):
|
||||
comment = comments[field]
|
||||
|
@ -1,6 +1,7 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import traceback
|
||||
from ajax import encode_query
|
||||
from dom import set_css
|
||||
from elementmaker import E
|
||||
@ -76,8 +77,8 @@ class Boss:
|
||||
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 and error_object.stack:
|
||||
details = error_object.stack
|
||||
if error_object:
|
||||
details = traceback.format_exception(error_object).join('')
|
||||
error_dialog(_('Unhandled error'), msg, details)
|
||||
return True
|
||||
except:
|
||||
|
@ -1,6 +1,7 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# 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.search import SearchPanel
|
||||
from book_list.top_bar import TopBar
|
||||
@ -196,7 +197,7 @@ class UI:
|
||||
data = JSON.parse(xhr.responseText)
|
||||
boss.change_books(data)
|
||||
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)
|
||||
window.scrollTo(0, 0)
|
||||
elif end_type is not 'abort':
|
||||
|
@ -1,6 +1,7 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import traceback
|
||||
from ajax import ajax_send
|
||||
from dom import set_css, build_rule, clear
|
||||
from elementmaker import E
|
||||
@ -145,8 +146,8 @@ class BooksView:
|
||||
raise Exception('No books ids object in search result from server')
|
||||
self.render_ids(data.search_result.book_ids)
|
||||
self.interface_data.search_result = data.search_result
|
||||
except Exception as err:
|
||||
error_dialog(_('Could not get more books'), _('Server returned an invalid response'), err.stack or err.toString())
|
||||
except Exception:
|
||||
error_dialog(_('Could not get more books'), _('Server returned an invalid response'), traceback.format_exc())
|
||||
elif end_type is not 'abort':
|
||||
error_dialog(_('Could not get more books'), xhr.error_html)
|
||||
|
||||
@ -230,7 +231,7 @@ class BooksView:
|
||||
data = JSON.parse(xhr.responseText)
|
||||
boss.change_books(data)
|
||||
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)
|
||||
window.scrollTo(0, 0)
|
||||
elif end_type is not 'abort':
|
||||
@ -251,7 +252,7 @@ class BooksView:
|
||||
data = JSON.parse(xhr.responseText)
|
||||
boss.change_books(data)
|
||||
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()
|
||||
ed = xhr.extra_data_for_callback
|
||||
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>
|
||||
from __python__ import bound_methods
|
||||
|
||||
import traceback
|
||||
from aes import GCM
|
||||
from gettext import install
|
||||
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:
|
||||
console.log('Error in iframe message handler:')
|
||||
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:
|
||||
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>
|
||||
# globals: __RENDER_VERSION__
|
||||
|
||||
import traceback
|
||||
from ajax import ajax, encode_query
|
||||
from elementmaker import E
|
||||
from gettext import gettext as _
|
||||
@ -138,10 +139,10 @@ class ReadUI:
|
||||
xhr.error_html)
|
||||
try:
|
||||
manifest = JSON.parse(xhr.responseText)
|
||||
except Exception as err:
|
||||
except Exception:
|
||||
return self.show_error(_('Failed to load book manifest'),
|
||||
_('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:
|
||||
return self.show_error(_('calibre upgraded!'), _(
|
||||
'A newer version of calibre is available, please click the reload button in your browser.'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user