Jump to content

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


Autoseek
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...