Exception Handling

Hi All,

I had a question about Exception handling and good coding standards.
Here is what i can came up with and would like to get a feed back from you folks.

    1    SEQUENCE (exit on sucess) 
     1.1    SEQUENCE (exit on failure) 
                                      Business Logic  
     1.2    SEQUENCE (exit on failure) 
              1.21    INVOKE getLastError  
              1.22    INVOKE logToFile  

2 SEQUENCE (exit on done)
2.1 INVOKE closeAll
2.2 INVOKE clearPipeline

Looking forward for your responses,

Thanks,

Gamad

I’ve had good luck with this sequence:

1 Sequence ‘Main’ (exit on done)
1.1 Sequence ‘Try’ (exit on success)
1.11 Business Logic
1.12 Business Logic
1.13 Exit Sequence ‘Main’
1.2 Sequence ‘Catch’
1.21 Exception Handling
1.22 Exit Sequence ‘Main’

In this, if sequence 1.1 completes normally, then step 1.13 enacts and the flow is exited. If, for example, 1.12 fails, then the process exits 1.1, but since ‘Main’ requires completion the process proceeds to 1.2, where the exception handling stuff is placed.

Hope this helps!

Gamad–the flow you outlined looks just like the try/catch handling recommended in the wM GEAR docs. That is what I’ve used with success throughout the projects I’ve worked on.

Matthew–I assume that in 1.1 you meant to type (exit on failure). If you have exit on success, if step 1.11 succeeds the sequence will exit, skipping over 1.12 and 1.13. Set 1.1 to exit on failure and you can dump step 1.13. You can also dump step 1.22 as it is essentially a no op.

Also, in 1 it’s usually set to EXIT ON SUCCESS so that the catch block doesn’t get executed upon a successful ‘try’ block. The Catch is usually EXIT ON DONE so that each step within the catch will be attempted.