Sign in to follow this  
Followers 0
Jewtus

Error logging

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

 

Share this post


Link to post
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.

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

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

 

Share this post


Link to post
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."


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

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.

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