mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Printout tracebacks in debug mode for exception during template processing
This commit is contained in:
parent
73e7ddcefe
commit
965db88065
@ -13,6 +13,8 @@ from calibre.utils.config_base import tweaks
|
||||
|
||||
class LockingError(RuntimeError):
|
||||
|
||||
is_locking_error = True
|
||||
|
||||
def __init__(self, msg, extra=None):
|
||||
RuntimeError.__init__(self, msg)
|
||||
self.locking_debug_msg = extra
|
||||
|
@ -515,8 +515,8 @@ class TemplateFormatter(string.Formatter):
|
||||
try:
|
||||
ans = self.evaluate(fmt, [], kwargs).strip()
|
||||
except Exception as e:
|
||||
# if DEBUG:
|
||||
# traceback.print_exc()
|
||||
if DEBUG and getattr(e, 'is_locking_error', False):
|
||||
traceback.print_exc()
|
||||
ans = error_value + ' ' + e.message
|
||||
return ans
|
||||
|
||||
@ -529,7 +529,7 @@ class ValidateFormatter(TemplateFormatter):
|
||||
|
||||
def validate(self, x):
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
self.book = Metadata('');
|
||||
self.book = Metadata('')
|
||||
return self.vformat(x, [], {})
|
||||
|
||||
validation_formatter = ValidateFormatter()
|
||||
|
Loading…
x
Reference in New Issue
Block a user