From 1e275fc669e22203d2be671b46385bdede799816 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Thu, 21 May 2020 18:11:55 +0100 Subject: [PATCH] Improve printed error message if a template function fails to compile. --- src/calibre/utils/formatter_functions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/formatter_functions.py b/src/calibre/utils/formatter_functions.py index fdd969a918..b1e2679350 100644 --- a/src/calibre/utils/formatter_functions.py +++ b/src/calibre/utils/formatter_functions.py @@ -1707,7 +1707,13 @@ def compile_user_template_functions(funcs): cls = compile_user_function(*func) compiled_funcs[cls.name] = cls except: - traceback.print_exc() + try: + func_name = func[0] + except: + func_name = 'Unknown' + print('**** Compilation errors in user template function "%s" ****' % func_name) + traceback.print_exc(limit=0) + print('**** End compilation errors in %s "****"' % func_name) return compiled_funcs