Jump to content

Error logging


Jewtus
 Share

Go to solution Solved by water,

Recommended Posts

I have two event handlers

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$oLogError = ObjEvent("AutoIt.Error","MyLogFunc")
$logFile = @ScriptDir & "\Log.txt"


Func MyLogFunc()
  $HexNumber=hex($oLogError.number,8)
  FileWrite($logFile,"_______------- Error @"& @MON & "/" & @MDAY & "/" & @YEAR & @TAB & @HOUR & ":" & @MIN & ":" & @SEC &"-------_______"       & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(0)  ; to check for after this function returns
Endfunc


Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  MsgBox(0,"","_______------- Error -------_______"       & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(0)  ; to check for after this function returns
Endfunc

and the thing that I cannot figure out is why I get no pop up message boxes, but I get the following over and over again in my log file:


 

_______------- Error @09/30/2014 08:21:41-------_______

err.description is:
err.windescription:
err.number is: 80020009
err.lastdllerror is:
err.scriptline is:
err.source is:
err.helpfile is: 

 

When I look it up, I find that that specific error is caused by an ODBC connection that I have.

Why would I not get a msg box but it does write to the file?

Edited by Jewtus
Link to comment
Share on other sites

I'm sorry if my understanding is off, but there are no MsgBox's in your script and you are only writing to a file..

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Developers

You are defining 2 ObjEvent() definitions for the same object which I guess isn't possible and only the last is performed.

I'm sorry if my understanding is off, but there are no MsgBox's in your script and you are only writing to a file..

Scroll down in the codebox. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You are defining 2 ObjEvent() definitions for the same object which I guess isn't possible and only the last is performed.

Scroll down in the codebox. ;)

Jos

Got it ;)

One was a MsgBox the other was just a FileWrite, which is why he was only getting FileWrites because it was only getting in an error in MyLogFunc().

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Solution

Taken from this page in the help file:

"A note for UDF writers

You can have as many COM Error Event Handlers. The last registered and alive object is the one that gets called."

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Taken from this page in the help file:

"A note for UDF writers

You can have as many COM Error Event Handlers. The last registered and alive object is the one that gets called."

That explains it! Thanks.

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...