How do you count errors using function

Hi,

I’m trying to use a function to count the number of errors I got in my scripts. I created many modules for my projects and I run them all using a module with all those projects in the helper. Also I made a module with many functions. So… for this function, I would like to put it in there to use it in other modules.

This is what I want the function to do
Takes two params (string and number)
string will be error message
number will be -1 or 0 or 1
if number is -1
display total number of errors
display all the error messages in the list
if number is 0
do nothing
if number is 1
add 1 to number of errors
add error message to a list
end of function

It will really help even if I can get some hint of how to do this.
The number kept on resetting to 0 and didn’t add up properly when I tried to do it myself :?.

What I mean by error is not Eggplant error. When you logerror I just want to put something like “Error”.LogError(“Error with something”, 1) so it keeps track of it. Not when Eggplant abort the script and say it couldn’t find image.

Jason,

What I have done is used a global variable called numFailed. I use this variable with each handler. We have a handlers that logs our own errors when a test script fails. So it would look something like this…

On testcase
global numFailed

try
Do some testing
catch
LogError “testcase failed”
put numFailed+1 into numFailed
end try

So during every catch I increment numFailed and at the end of the test run or group of runs I publish the total.

OK that helped. Thank you!