------------------------------
Chip Orange
Database Administrator
Florida Public Service Commission
chip.ora...@psc.state.fl.us
(850) 413-6314
(Any opinions expressed are solely those of the author and do not
necessarily reflect those of the Florida Public Service Commission.)
> -----Original Message-----
> From: Ron Parker [mailto:r...@gwmicro.com]
> Sent: Thursday, August 20, 2009 4:50 PM
> To: gw-scripting@gwmicro.com
> Subject: Re: a "standard" VBScript feature won't work in WE
>
> Chip Orange wrote:
> > I can't do it in a WE script however; it simply halts on the line
> > having the error. I'm not using GWToolkit error handling
> in any way.
>
> That code was very weirdly formatted. Either whoever wrote it was
> trying to make what he was doing look more mysterious, or he
> was just on
> crack.
>
> The difference between WSH and Window-Eyes is that for
> whatever reason,
> WSH apparently doesn't try to handle that error by popping up
> a dialog
> box. We do. However, you can override that behavior for
> your script by
> offering to handle the OnError event yourself. Obviously, if you do
> that, you should be prepared to deal with errors that occur
> outside of
> your pseudo-try block, perhaps by deferring to the toolkit error
> handling in those cases. In my test, I just handled all errors by
> ignoring them completely. If you do this, though, note that we will
> still know the error happened, and we'll set your status to "Running
> with Errors" in the script manager.
>
> Anyway, this code seems to do more or less what you expect
> with Window-Eyes:
>
> ' ======8<--- cut here ---------
>
> Class CFunc1
> Private Sub Class_Initialize
> DoLog "Starting"
> Dim i : i = 65535 ^ 65535
> MsgBox "Should not see this"
> End Sub
> Private Sub CatchErr
> If Err.Number = 0 Then Exit Sub
> Select Case Err.Number
> Case 6 DoLog "Overflow handled!"
> Case Else DoLog "Unhandled error " & Err.Number & "
> occurred."
> End Select
> Err.Clear
> End Sub
> Private Sub Class_Terminate
> CatchErr
> DoLog "Exiting"
> End Sub
> Private Sub DoLog( a )
> MsgBox a
> End Sub
> End Class
>
> Sub OnError( path, name, desc, source, wcode, scode, line, column )
> End Sub
>
> ConnectEvent Script, "OnError", "OnError"
>
> Dim Func1
> Set Func1 = New CFunc1
> Set Func1 = Nothing
>
> ' ======8<--- cut here ---------
>
thanks Ron; another keeper for my library. I'm trying to deal with an
activex control, which could have any method blow up at any time, and I
just didn't want to surround every single use with on error resume ...
I thought this looked intreaguing , so I'll experiment and
see if it's worth it or not.
Chip