Jump to content

Advanced error handling brainstorming


Recommended Posts

If AutoIt is used for small scripts only, the current error system is great. Really simple and powerful.

When it comes to bigger scripts that include other scripts (that include other scripts etc.), simple @error values or custom error codes as return values might not make it.

For example, some utility function on the top of a call stack want's to deliver an error message to the main script along the stack (Don't know if I'm using the term "stack" correctly here..). It might get messy to handle the error as return values many times until the error handling "parent function" receives it.

Am I making myself clear?

Anyway, exception handling is the holy grail here but I've got a feeling it won't be implemented. Also, any other error systems won't be created at least during this century. Therefore we have to think something up. I'm about to create something more advanced to ease up the error handling logic. Maybe a UDF. I really, and likely others too, would like to hear about error systems you have created or planned. Also views on how it should be done are appreciated.

OR MAYBE thinking like this is just waste of time: The scripts have just become way too large and it's time to move another language?

EDIT: Some interesting discussion about exceptions and AutoIt: [link]

Edited by amokoura
Link to comment
Share on other sites

  • Moderators

If AutoIt is used for small scripts only, the current error system is great. Really simple and powerful.

When it comes to bigger scripts that include other scripts (that include other scripts etc.), simple @error values or custom error codes as return values might not make it.

For example, some utility function on the top of a call stack want's to deliver an error message to the main script along the stack (Don't know if I'm using the term "stack" correctly here..). It might get messy to handle the error as return values many times until the error handling "parent function" receives it.

Am I making myself clear?

Anyway, exception handling is the holy grail here but I've got a feeling it won't be implemented. Also, any other error systems won't be created at least during this century. Therefore we have to think something up. I'm about to create something more advanced to ease up the error handling logic. Maybe a UDF. I really, and likely others too, would like to hear about error systems you have created or planned. Also views on how it should be done are appreciated.

OR MAYBE thinking like this is just waste of time: The scripts have just become way too large and it's time to move another language?

For larger projects, I generally use something like Dales IE.au3 error handling in any language I'm writing in.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

For larger projects, I generally use something like Dales IE.au3 error handling in any language I'm writing in.

Which means (in AutoIt) seterror() with some predefined error enums? I'm attracted to that idea too but it doesn't have the ability to include any additional data about the error.

Link to comment
Share on other sites

Which means (in AutoIt) seterror() with some predefined error enums?

What? Have you even opened IE.au3 to look at it? That was a pretty clueless comment there.

There is a heck of a lot more going on there than @error codes, and you would learn much by checking it out.

:P

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

There is a heck of a lot more going on there than @error codes, and you would learn much by checking it out.

I checked out the IE UDF that was included with the Autoit installation. All I really saw was error/status codes and notifying of errors and warnings to console. I might be stupid but I don't see anything special there.. help me!

Link to comment
Share on other sites

  • Moderators

I checked out the IE UDF that was included with the Autoit installation. All I really saw was error/status codes and notifying of errors and warnings to console. I might be stupid but I don't see anything special there.. help me!

No no no ... lol.

__IEErrorNotify(), Look at that function.

Edit:

Not really much more you can do in this situation without going non-native.

It provides an option to state:

Severity, ie.. Warning, Error, Whatever

The function it happened in

Status would be the error code

And a message

You can also setup details within the Error function itself. I usually setup a switch statement, and depending on the error, it will do different things.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

No no no ... lol.

__IEErrorNotify(), Look at that function.

Edit:

Not really much more you can do in this situation without going non-native.

It provides an option to state:

Severity, ie.. Warning, Error, Whatever

The function it happened in

Status would be the error code

And a message

You can also setup details within the Error function itself. I usually setup a switch statement, and depending on the error, it will do different things.

OK I get it (maybe), thanks :P

The __IEEErrorNotify() seems to just build an error message that is built of given parameters and writes it to console.

Func __IEErrorNotify($s_severity, $s_func, $s_status = "", $s_message = "")
    If $_IEErrorNotify Or $__IEAU3Debug Then
        Local $sStr = "--> IE.au3 " & $IEAU3VersionInfo[5] & " " & $s_severity & " from function " & $s_func
        If Not String($s_status) = "" Then $sStr &= ", " & $s_status
        If Not String($s_message) = "" Then $sStr &= " (" & $s_message & ")"
        ConsoleWrite($sStr & @CR)
    EndIf
    Return 1
EndFunc   ;==>__IEErrorNotify

That is neat but not what I'm searching. Apparently I wasn't clear enough.

I'm trying to reach something that exception handling has to offer. The idea of creating an error and passing the failure data along the call stack to the function that wants to handle it. Currently the structure of the error isn't my concern. The thing you guys mentioned is pure gold on that one, though.

You raised an interesting point about going non-native. That's actually what I'm wondering. Is it possible to take the error handling a little bit further in AutoIt?

I had an example script [link] trying to ease the pain but it turned out to be crap. You might get the basic idea if you check out the post. I'm planning another system and it seems quite elegant. Almost exceptionish :P

Edited by amokoura
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...