Sign in to follow this  
Followers 0
edgariyu

How to not stop a script?

4 posts in this topic

Hi everyone!

I would like to know how could i make not stop a script if something happens. I'm using the funcion:

$WinHttpReq = ObjCreate("winhttp.winhttprequest.5.1")   ;Realizamos la peticion HTTP
$WinHttpReq.open("GET",$page)
$WinHttpReq.send()

and the problem i have is that if the page i'm opening is down or something goes wrong the script stops.

I know that the answer is in a Object handler and it's something like:

Global $g_eventerror = 0 

$WinHttpReq = ObjCreate("winhttp.winhttprequest.5.1")   ;Realizamos la peticion HTTP
$WinHttpReq.open("GET",$page)
if $g_eventerror = 1 then
  $WinHttpReq.send()
else
  consolewrite("Error on page")
endif

Func MyErrFunc() 
local $HexNumber= hex($oMyError.number,8) 
If $HexNumber<> (80020009 or 80070005) Then
   ConsoleWrite("On Load error")
   $g_eventerror = 1 ; something to check for when this function returns 
EndIf
Endfunc

but i'm missing something because i don't know how to get the concrete error number to handel the error. The function $WinHttpReq.send() sometimes gets an error (The requested action with this object has failed) and i don't know how to make the script not to stop. I've read the object page but still continue with doubts.

Is there anyone with experience dealing with this objects reference that cound help me to solve this problem?

Thanks a lot!!

Share this post


Link to post
Share on other sites



Have a look in the help file while ... wend / do ... until

Share this post


Link to post
Share on other sites

Have a look in the help file while ... wend / do ... until

You are over 13, right?

@edgariyu, try something like this:

; Error object
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ; Nothing
EndFunc


; Main code:
Global $oWinHttpReq = ObjCreate("winhttp.winhttprequest.5.1")
$oWinHttpReq.Open("GET", "http://something to cause error")

$oWinHttpReq.Send()
If $oError.number Then
    MsgBox(48, "Error", "Error sending request. Number is 0x" & Hex($oError.number, 8))
    $oError.clear()
EndIf

ConsoleWrite("Still alive!" & @CRLF)
; ...whatever here...

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Thanks for the answer! I'll try what you suggest :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0