problem processing COMException in VB6
Jim Kerr
jim_kerr at agilent.com
Tue Oct 9 16:04:03 EDT 2001
Using DISP_E_EXCEPTION didn't work either; VB displayed the message
"Automation error - exception occurred"
which again suggests that only the scode is being consulted, not the
description.
After poking around a bit, I discovered that you can force VB to
display your description string if you set the facility code to
FACILITY_ITF (= 4), and use a custom error code greater than 0x200, as
in:
raise COMException(desc="Your message goes here", scode=0x80040201)
I'll leave it to the experts to decide if it's best to express the
scode as
scode = winerror.OLE_E_OLEVERB | MYCUSTOMHRESULT
or some other symbolic representation instead of hardcoding the value.
Jim
Mark Hammond <MarkH at ActiveState.com> wrote in message news:<3BBBBE74.20509 at ActiveState.com>...
> Jim Kerr wrote:
> ...
>
> > raise COMException(desc="No measurement defined on channel %d" %
> > channelNum, scode=winerror.DISP_E_BADINDEX)
> >
> > and the VB client catches the exception with
> >
> > MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Server
> > Error"
> >
> > then the message box displays the text "Subscript out of range"
> > instead of "No measurement defined on channel 3".
>
>
> It is likely that VB is treating DISP_E_BADINDEX specially. Try using
> DISP_E_EXCEPTION.
>
> Mark.
More information about the Python-list
mailing list