Page 1 of 1

Server Routine causing Exception Handler to trigger

Posted: Wed Jan 03, 2018 1:04 pm
by jackson.eyton
Hi Everyone,
I have a pretty basic routine that reads the contents of a text file. The routine does work successfully, but it appears if I enable "Automatically handle activities that fail" in my sequence job properties, this sequence causes the job's exception handler to trigger, even though it was in fact successful at reading the file. The code for the routine is as follows:

Code: Select all

Routine = 'ReadFile'


vFileName = Arg1

vArray = ''

vCounter = 0



OPENSEQ vFileName to vFileHandle

Else Call DSLogFatal("Error opening file list: ":vFileName,Routine)

Loop

While READSEQ vLine FROM vFileHandle

vCounter = vCounter + 1

vArray<vCounter,1> = Fields(vLine,',',1)

vArray<vCounter,2> = Fields(vLine,',',2)

vArray<vCounter,3> = Fields(vLine,',',3)


Repeat

CLOSESEQ vFileHandle


Ans = vArray
Here is the Summary of Sequence run:
  • WireXchange_Processor..JobControl (@Coordinator): Summary of sequence run
    12:36:47: Sequence started
    12:36:47: Wait_For_File (ROUTINE DSWaitForFile) started
    12:36:47: Wait_For_File finished, reply=0
    12:36:47: DateTime (JOB DateTimeToString) started
    12:36:51: DateTime (JOB DateTimeToString) finished, status=1 [Finished OK]
    12:36:52: Read_Date_Time_String (ROUTINE DSU.ReadFile) started
    12:36:52: Read_Date_Time_String finished, reply=2018-01-03_1236_PM
    12:36:52: Exception raised: @Read_Date_Time_String, Unhandled failure (2018-01-03_1236_PM ) encountered calling routine DSU.ReadFile
    12:36:52: Exception handler started

    12:36:52: Failure_Email (ROUTINE DSSendMail) started
    12:36:52: Failure_Email finished, reply=0
    12:36:52: Sequence finished OK
note the lines in bold, its as if it's reading the contents of the file itself as the failure message?

Posted: Wed Jan 03, 2018 1:43 pm
by Mike
A routine activity must return 0 (reply=0) or it will trigger the exception handler.

I suggest calling your routine from a user variable.

A routine that returns anything besides zero requires a trigger to handle that non-zero reply.

Mike

Posted: Wed Jan 03, 2018 2:07 pm
by chulett
Your other option is to note the fact that it is handling it because it thinks you are not - hence the "unhandled exception" noted in the log. If you explicitly have triggers that cover failure, say an "okay" and an "otherwise" trigger (even if both go to the same spot), it will not trigger that exception handler. This used to be noted in the documentation along with specific trigger examples for those options, I assume it's still there. Somewhere. :wink:

Posted: Thu Jan 04, 2018 1:08 pm
by jackson.eyton
Thanks Gentlemen!
I did indeed call the routine from a user variable, which highlighted an idiot mistake I had made as the very next stage after my Routine Activity stage was a UserVariable Activity stage to trim the returned value of the routine activity... Doh! Consolidated that into JUST the UserVariable and that took care of that. I did end up disabling automatic exception handling in lieu of using a sequencer set to ANY and using failure triggers from each important stage in the job. I used another UserVariables Activity stage and nested IF THEN ELSE to get the name of the failed job/stage for use in the email notification subject.