Sign in to follow this  
Followers 0
Autoseek

How to catch errors when opening http-location with Obj.Open?

6 posts in this topic

Hi,

ok, >digging this out. I got this to work for me. Would someone be able to point me into the right direction for understanding the error handling of $oxmlhttp.Open ("GET", $url2, False)? It is my understanding that this is the major part of the retrieval, and if the retrieval does not work, I would like to understand why :)

I have looked here, https://www.autoitscript.com/autoit3/docs/intro/ComRef.htm, under "COM Error Handling", but I am not getting an error when trying to download (for provoking an error) from a non-existing location. Perhaps I am not even doing something meaningful, when trying to catch an error of $oxmlhttp.Open, but I am afraid that I am lacking too many basics here to find out.

If anybody can suggest the error handling here, that would make me very happy :D

Cheers

Autoseek

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I would first test to make sure you object is creating correctly (that is an old example you are using).

I use :
dim $winHttpReq = ObjCreate("WinHttp.WinHttpRequest.5.1") ; create an instance of the winhttp object

See the help file for how to test if you are creating the object properly (I modified it a bit ... untested):

If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "ObjCreate Test", "ObjCreate() successful !")
 Else
    MsgBox($MB_SYSTEMMODAL, "ObjCreate Test", "Failed to create Object. Error code: " & Hex(@error, 8))
EndIf

Also, if you are just trying to get a file - you should look at the InetGet function.

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Hi,

Thank you for that "pointer on the side" to the InetGet function. I have rewritten everything based on InetGet and the examples provided there. It works smoothly. :thumbsup:

Great!

Cheers

Autoseek

Share this post


Link to post
Share on other sites

Adding this lines of code at the top of your script will grab all COM errors (if any) and display them in a separate window:

#include <Debug.au3>
_DebugSetup()
_DebugCOMError()

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi,

Thank you. Very interesting. Didn't know it's so easy to install an error handler :)

Cheers

Autoseek

Share this post


Link to post
Share on other sites

Ease of use was what I had in mind when I wrote this function :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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