Jump to content

Script Crash Error Reporting


Recommended Posts

I'm not sure if this post should go under "General Help and Support" or "Example Scripts".

I've heard of non-AutoIt programs that can create a crash report and dump a bunch of variable related information into it upon the program crashing. I've made a program and a few friends of mine will be using, however, I'm worried about it crashing and even more importantly, not having any idea why it crashed. Is there any way possible to have some kind of crash report or function run when a crash occurs. I understand that you can set a function to run when the script exits, but not when a crash is about to occur.

Any ideas?

Link to comment
Share on other sites

If you get AutoIt to crash, using valid code and not using any COM or Dll's then it's likely to be a bug. If you do use COM then you can use AutoIt.Error event, look at ObjEvent.

You can create your own crash reports from AutoIt, because the likelyhood it will hard crash is very small.

I am not using COM or DLLs. Just the normal AutoIt code. You say I can create my own crash reports but how do I do this? That's what I don't understand? I have to have some kind of way of executing a function or an other program that can read the value of different variables for the main program. But if the program is crashing/crashed, there is no way for it to run an other function, it has already crashed.

What would be nice is if there was a feature that when a script comes across an error that will cause it to crash, that it gives you then ability to run a function before the script closes. That away you can dump as much info about current program settings and variable values into a files.

Anyway, can you give me an example of how to create a crash report file for a normal AutoIt script? All I really want to do is create a file, dump different key variables' values to the file, then close the file. If you can show me how to do this then it would make my day!

Link to comment
Share on other sites

If you're only using normal AutoIt code, then you can write better code and prevent the crash. Or, you can capture the "crash" before it happens using proper error checking.

For example, you normally would:

$var = PixelSearch( .. parameters .. )
$x = $var[0]
$y = $var[1]oÝ÷ Ø­¶§óâÅéRyªÜö¢Ëh~)ݶ¢Z+z®zËb¢|¨»]ëZªëk'«®ôß«Ú®+'¢Ö§jºÚÉ*2¢ì(ºW]¡«­¢+ØÀÌØíÙÈôA¥á±MÉ  ¸¸ÁɵÑÉ̸¸¤)%9½ÐÉɽÈQ¡¸(ÀÌØíàôÀÌØíÙÉlÁt(ÀÌØíäôÀÌØíÙÉlÅt)¹%
Link to comment
Share on other sites

Alright. Well that's not what I was looking for at all. Thanks for the help. I know I can wright better code, that's what I'm working on. And checking for an error is only good if you know there could be an error there. But when your working with code that has over 1000 lines before you add extra, it's just too much. Plus, then you have to add error checking for everything that could cause and error. You will probably double how much code the CPU has to execute. On top of this, the code for checking errors can have an error itself, once again causing the code to crash.

Here is what I know I can do right now:

Opt("OnExitFunc", "OnAutoItExit")


If $Test <> "No Set" Then Exit(10)


Exit(12)


Func OnAutoItExit()
    MsgBox(0, "Exit Code", "The exit code is: " & @ExitCode)
EndFunc

Now if you ran the script, it would crash with an error code of 1 and without the function OnAutoItExit() running. I'd like to have a way of running a function of some type, even on a crash. Some kind of system so that I could dump the value of all the variables into a .txt file, and maybe what line the script was one. This would really help me out as a developer.

Link to comment
Share on other sites

I'm going to paraphrase a bit, because I read this a while ago and don't feel like digging for the thread. There was a dicussion about creating custom error messages, so in the even of a crash (even from bad coding) autoit could display a different message then it does now.

The answer is that can't really be done because once autoit determines its no longer safe to execute code(from the error), it isn't safe to execute the code for a custom function. To get around that, autoit would have to determine what is safe code versus what isn't safe. Take your example, the error is because you didn't declare your variable, how can you print out the value of it when that in itself is the error. Its just not close to practical, if even possible. To help with crashes while not compiled, add #AutoIt3Wrapper_run_debug_mode=Y to the top of your script to have Scite run in debug mode. That isn't going to help when compiled though.

I think your overestimating how hard it would be to write code with error checking. It isn't going to double how much the CPU does. It might be tedius to incorporate into a script you already made, but really not that hard. As for error checking the code for error checking... again your overthinking it. For the example, simply using Dim $Test would clear up the error.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
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...