Respect debug-on-error for error reporting
Closed this issue · 6 comments
At the moment, pymacs returns a full backtrace for error. The backtrace is usually mutli-line and causes the minibuffer to enlarge, which is visually disturbing. In the following patch pymacs is made to respect debug-on-error.
I was surprised that the commit is merged so soon!!! Thanks, Pinard.
However, I re-read my patch more thoroughly and realised that I have missed an else: branch for PYTHON3. Could you fix it so that it mirrors the change for PYTHON2. Thanks.
Hi, Leo.
I'm a bit moot on this change, as personally, I like getting the full traceback when there is an error. I understand that others may feel differently however. It may be annoying having to set debug-on-error to get it, I'm not sure. I'm merging your change, and we'll see if people want to express an opinion about it. In any case, thanks for this change, and the others you also did.
Also, having a short error is convenient when the programmer of the application raises an error really meant to tell something to the user, but for programming errors (users would say "system errors"), a short traceback is likely meaningless.
Finally, the Python documentation does not say in which Python release functions like "format_exception_only" were introduced, so I do not know if accepting your correction would create problems for users installing Pymacs on older Python releases. I surely like that you avoid "io" and "StringIO". Short of knowing, let's risk it, and see! :-)
François
Keep happy!
François
Leo, you write:
realized that I have missed an else: branch for PYTHON3. Could you fix it so that it mirrors the change for PYTHON2
I may be the one missing something, as I think you took proper care of both branches in your patch. Would you be kind enough to tell me what you meant?
François
François,
Thanks a lot for getting this in.
The intention is to mirror what emacs does in event of error. `debug-on-error' can be turned on by M-x toggle-debug-on-error. In Emacs >= 23, you can type M-x to-err TAB and it will automatically complete to that. You might need to customise completion-styles to include partial-completion.
The fix I was talking about is something like this:
diff --git a/Pymacs.py.in b/Pymacs.py.in
index 312ba0f2..91c15d1a 100755
--- a/Pymacs.py.in
+++ b/Pymacs.py.in
@@ -225,6 +225,8 @@ class Protocol:
value = traceback.format_exception_only(sys.exc_type,
sys.exc_value)
value = ''.join(value).rstrip()
+ else:
+ value = traceback.format_exc()
if not done:
fragments = []
print_lisp(value, fragments.append, True)
I still mostly use py2 so this bug went unnoticed for a while.
OK, got it, and applied. Thanks! :-)
Thanks!