ErrorHandling in ActiveX events 
Author Message
 ErrorHandling in ActiveX events

I came across the following whilst trying to use the WebBrowser wrapper. It
may be expected and it is my limited understanding of what should be
happening and/or what I should be doing that is wrong - but it's a bit
confusing. Demo.... edit the method

WebBrowserShell>>OnDocumentComplete: anIDispatch URL: urlOrPIDL
    self halt

and start up the WebBrowserShell application. It, as expected, halts almost
straight away. Now edit the method to read

WebBrowserShell>>OnDocumentComplete: anIDispatch URL: urlOrPIDL
    #(1 2 3) detect: [:e | e > 10].
    self halt

Now, not only does the #detect not bring up the expected error but the #halt
also fails to work.

Ian



Mon, 19 May 2003 03:00:00 GMT  
 ErrorHandling in ActiveX events

Quote:
> I came across the following whilst trying to use the WebBrowser wrapper.
It
> may be expected and it is my limited understanding of what should be
> happening and/or what I should be doing that is wrong - but it's a bit
> confusing. Demo.... edit the method

> WebBrowserShell>>OnDocumentComplete: anIDispatch URL: urlOrPIDL
>     self halt

> and start up the WebBrowserShell application. It, as expected, halts
almost
> straight away. Now edit the method to read

> WebBrowserShell>>OnDocumentComplete: anIDispatch URL: urlOrPIDL
>     #(1 2 3) detect: [:e | e > 10].
>     self halt

> Now, not only does the #detect not bring up the expected error but the
#halt
> also fails to work.

Like much strange behaviour, the simplest explanation is actually the
correct one :-). If you look at the implementation of
AXDispatchImpAbstract>>Invoke:rid:lcid:&c you will immediately see why. All
errors are trapped and converted to an HRESULT code to be returned to the
caller.

You may wonder why this is done, and I was in two minds about it myself. The
point is that one is acting as a COM server in implementing the dispatched
methods or events, and the correct behaviour in a runtime situation would be
to return an error code to the caller, not raise an exception, because COM
doesn't allow one to pass exceptions across interfaces.

So, converting the exceptions to HRESULT codes is the correct behaviour for
a runtime app., but it does make debugging harder I will agree. I think what
is needed is a capability like one sees in VC++, where one can specify the
whether to break when certain exceptions occur, or only if they are not
handled. Maybe just a simple routing via the SessionManager so that the
development session manager could behave differently (although even then one
needs to be able to turn off the trap in order to test the actual runtime
behaviour of the application). As you can see I'm still thinking about how
to enhance the tools for better debuggability of COM servers.

In the meantime either keep an eye out for "Error dispatching " methods on
the Transcript (and yes, I'm also thinking about how to make the Transcript
flash in the way that MSN Messenger does when it needs attention), or add a
temporary override of #errorDispatching:&c to AXEventSink which perhaps has
a breakpoint in it.

Regards

Blair



Mon, 19 May 2003 03:00:00 GMT  
 ErrorHandling in ActiveX events
Blair,

Thanks for the run through Blair, it does make sense when you explain it.

Quote:
> In the meantime either keep an eye out for "Error dispatching " methods on
> the Transcript (and yes, I'm also thinking about how to make the
Transcript
> flash in the way that MSN Messenger does when it needs attention), or add
a
> temporary override of #errorDispatching:&c to AXEventSink which perhaps
has
> a breakpoint in it.

Doh, I never thought of checking the Transcript - it does clearly show that
something was going wrong. Perhaps a "ding" when an error message is output
might draw attention?.

Ian



Mon, 19 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ActiveX events

2. APL+Win ActiveX event handling

3. Activex events for InternetExplorer.Application

4. How to handle ActiveX events?

5. ActiveX events don't fire with 6i ?

6. ActiveX Events in Labview are not working

7. Cannot receive ActiveX Controls Events in LV

8. ActiveX Events in Labview are not working

9. ActiveX tree control's wiat event does not abort after nodes are added

10. ActiveX event missing

11. Eksampels of ActiveX Events

12. ActiveX Events from ATL Automation Server?

 

 
Powered by phpBB® Forum Software