On 20/04/2012 8:30 AM, Lloyd Kvam wrote:
On Thu, 2012-04-19 at 16:32 -0400, Lloyd Kvam wrote:
I am hoping one of you can point me in the right direction.  My
alternative appears to be (painfully) writing some VB code to discard
the traceback lines from  Err.Description.

Hrm - I thought it had always been the case that if you throw an explicit COMException, then you shouldn't get the traceback - the traceback only appears for "other" exceptions, which presumably indicate the exception was unintended.


I read more carefully through Python Programming on Win32 and came up
with this code:

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
class DefaultDebugDispatcher(
        win32com.server.dispatcher.DefaultDebugDispatcher):
     def _HandleException_(self):
         excls,exself = sys.exc_info()[:2]
         if not IsCOMServerException(excls):
             raise COMException(description = str(exself),
                 scode = winerror.E_INVALIDARG,
                 )

Which seems to backup my point - IsCOMServerException() is returning false, so the exception isn't a COMException, so you turn it into one and avoid the traceback etc.

Note however that you could just also raise a COMException directly from the original point - ie, there should be no need to convert to a COMException if a COMException is thrown in the first place.

How are you throwing the original? If you thought you were throwing a COMException then we would want to check you actually are if you still think so, dig into why IsCOMServerException is failing.

Cheers,

Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to