Sign in to follow this  
Followers 0
ShadoWarrior

how to log runtime error?

6 posts in this topic

#1 ·  Posted (edited)

I've built a script that runs on the background of my computer.... and it needs to run for hours so i can't track it manually all the time

and their are always bug to be fixed...

i want to write a script that monitor the first one and log it's runtime errors with details.

thought of using "StderrRead" but i don't quite understand how to use it...

#include <Constants.au3>

Global $FileName = IniRead("Setting.ini", "Monitors", "Machine", "NotFound") & "/ErrorStdOut" ; "first" auto-it script already compiled  
Global $Location = IniRead("Setting.ini", "Monitors", "Location", "NotFound")

Local $foo = Run($FileName ,$Location,@SW_HIDE,$STDERR_CHILD)
Local $line

While 1
    $line = StderrRead($foo)
    If @error Then
         MsgBox(0, "STDERR read:", $line)
         ExitLoop
    EndIf
    Sleep(1000)
Wend

MsgBox(0, "Debug", "Exiting...")

tried to use this simple script but $line just return blank after a runtime error...

Edited by ShadoWarrior

Share this post


Link to post
Share on other sites



I'm lost... ;)

I just need a way to log the script runtime errors into a log file...

any help will be appreciated.

Share this post


Link to post
Share on other sites

thought of using "StderrRead" but i don't quite understand how to use it...

That will only work if you're writing to the STDOut in the first place, StdinWrite().

I'm lost... ;)

I just need a way to log the script runtime errors into a log file...

any help will be appreciated.

What kind of errors are we talking about here? Are you dealing with COM, Arrays with incorrect subscript dimensions? What?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Perhaps you could do something crude such as adding throughout your code

If @error then _errorlog(@error)
ExitLoop

And having a function

#include <file.au3>

Func _errorlog($error)
    _FileWriteLog(@ScriptDir, $error, -1)
        ;Some other code
EndFunc
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

most of the error i get are related to arrays.

what i need is to see where the error occurred in the original script so i can fix it...

but the script work in a compiled form, so any info regarding the source of the problem dissipates into a general error box...something like error in line -1.

I'm looking for a way to log all the errors that makes the script stop.

Share this post


Link to post
Share on other sites

Perhaps you could do something crude such as adding throughout your code

[ code='text' ] ( Popup )

If @error then _errorlog(@error) ExitLoop

And having a function

[ code='text' ] ( Popup )

#include <file.au3> Func _errorlog($error) _FileWriteLog(@ScriptDir, $error, -1) ;Some other code EndFunc

it's a very good idea JohnOne but the script is very very long and bugs can have many forms and be anywhere...

i just what to be able to see the error info as i would if the script wasn't compiled

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