Sign in to follow this  
Followers 0
rassillon

AutoIt.Error Source (Happy New Year)

3 posts in this topic

I am having a problem.

I am writing a COM error handler for a project I am working on and it appears that the Error object is missing the "source" property.

Global $Global_com_error_object = ObjEvent("AutoIt.Error", "_com_error_handler")

Func _com_error_handler()
Local $_com_error_text
If @Compiled Then
  $_com_error_text = "COMERR : " & _
  "[.number : '" & Hex($Global_com_error_object.number,8) & "']," & _
  "[.windescription : '" & $Global_com_error_object.windescription & "']," & _
  "[.source : '" & $Global_com_error_object.source & "']," & _
  "[.description : '" & $Global_com_error_object.description & "']," & _
  "[.helpfile : '" & $Global_com_error_object.helpfile & "']," & _
  "[.helpcontext : '" & $Global_com_error_object.helpcontext & "']," & _
  "[.lastdllerror : '" & $Global_com_error_object.lastdllerror & "']"
Else
  $_com_error_text = "COMERR : " & _
  "[.number : '" & Hex($Global_com_error_object.number,8) & "']," & _
  "[.windescription : '" & $Global_com_error_object.windescription & "']," & _
  "[.source : '" & $Global_com_error_object.source & "']," & _
  "[.description : '" & $Global_com_error_object.description & "']," & _
  "[.helpfile : '" & $Global_com_error_object.helpfile & "']," & _
  "[.helpcontext : '" & $Global_com_error_object.helpcontext & "']," & _
  "[.lastdllerror : '" & $Global_com_error_object.lastdllerror & "']" & _
  "[.scriptline : '" & $Global_com_error_object.scriptline & "']"
EndIf

Call($Global_com_error_object.source & "_" & Hex($Global_com_error_object.number,8))
If @error = 0xDEAD And @extended = 0xBEEF Then
  ConsoleWrite($_com_error_text & @crlf)
  ConsoleWrite("Custom COM error handler '" & $Global_com_error_object.source & "_" & Hex($Global_com_error_object.number,8) & "' does not exist."  & @crlf)
Else
  ConsoleWrite($_com_error_text & @crlf)
EndIf
    Return
EndFunc   ;==>_com_error_handler
$shell = ObjCreate("wscript.shell")
$shell.run()
ConsoleWrite(ObjName($shell) & @CRLF)

I have included a crude example that shows my issue.

I am attempting to be able to support custom error handling functions depending on what error and what object throws it.

I am open to suggestions if there is a better way to do this if I have missed some function that AutoIt already supports.

Currently my issue is that the "source" property has no value as demonstrated above.

I am still on 3.3.6.1 and am updating to 3.3.8 soon so if that is the issue, cool, if not....HELP...

Happy New Year All!

Thanks in advance!

Share this post


Link to post
Share on other sites



Not everything that can generate a COM Error provides the .source property. Your script will have to handle those exceptions. Also, Call() is a bad idea because the number of error .number values is huge, so you can't create a function for each one.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Not everything that can generate a COM Error provides the .source property. Your script will have to handle those exceptions. Also, Call() is a bad idea because the number of error .number values is huge, so you can't create a function for each one.

:)

Hey PsaltyDS,

Thanks for the reply.

Yeah, I know there are a butt-load of error numbers and multiply that by different objects it can become astronomical...

My plan is not to provide special handlers for *all* errors, just a select few that I have special plan B for....

I would just handle it straight in my code but I actually have potential for "plugin" scripts to be calling items in my code so as conditions that come up that I can actually do something about I wanted to be able provide hot patches and then updated versions.

I may have to revert to setting global variables before using an object... or something like that....

Thanks for your help!

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