Error Handling

Discuss RoboTask here
Post Reply
paraffin
Posts: 21
Joined: Thu Jul 19, 2018 8:31 pm

Error Handling

Post by paraffin »

Hi

Has anyone got an example of error handling that will allow me to only send an email alert when the job fails 3 times in a row?

We are working with a provider that has an SFTP server and it seems that on occasion it gets a bit flakey so I am getting a lot of alerts for a period and then it resolves itself.

Cheers in advance
David
Oleg
Site Admin
Posts: 3011
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Error Handling

Post by Oleg »

You can use global variable some counter. For example variable named GlobalCounter with initial value 1
And use it in error handler as in my example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1075658632
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task519"
Hide=INTEGER|0
ID=INTEGER|-366427919
LogOnAsUser=INTEGER|1
Name=STRING|"handler send a message at 3-d time"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action1\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"1"
value1=STRING|"{GLOBALCOUNTER}"
value2=STRING|"3"

[Actions\Action2]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//send a message and reset global counter"
Params=FOLDER

[Actions\Action2\Params]
comment=STRING|"send a message and reset global counter"

[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action3\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"5"
height=STRING|"76"
icon=STRING|"2"
kind=STRING|"0"
message=STRING|"Error raised 3 times"
position=STRING|"3"
title=STRING|"3-d time"
width=STRING|"330"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""GLOBALCOUNTER"" with value ""1"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varname=STRING|"GLOBALCOUNTER"
varvalue=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""GlobalCounter"""
Params=FOLDER

[Actions\Action6\Params]
incement=STRING|"1"
vaiable=STRING|"GlobalCounter"

[Actions\Action7]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

Do not forget create global variable GlobalCounter with value 1.
Next you can try this example. It shows a message only at 3-d running.
Oleg Yershov
Post Reply