[Tutor] How to raise error without the stack trace

Alan Gauld alan.gauld at btinternet.com
Sun Nov 27 17:36:54 CET 2011


On 27/11/11 12:11, Karim wrote:

> I just wanted to know if it is possible to control the stack trace
> display when raising my own exception.

No, and you should not try.

You can control the stacktrace display where you catch it, but not where 
you raise it. And that's the point, you are raising it because you don't 
want to handle it there. You are expecting the user to deal with the 
error, including how it is displayed.

Peter has already showed you how to do that by overridding the standard 
exception hook sys.excepthook..


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list