Would it be bad design to purposefully throw an error within a repeat to force an exit?
I am trying to simulate a Java WHILE loop within Developer without using Java services and thought that having a REPEAT ON SUCCESS would achieve that goal. When the condition is met, the error is thrown and the REPEAT is exited.
Sometimes you do have to throw and error instead of using the Exit from loop/parent step.
If your exit point is enclosed in a try-catch sequence pattern and you use the Exit from loop in the try section the getLastError step in the catch section does not give the details of the error message. If you throw and Exception instead it will show up in the catch section. This is useful for a error trapping wrapper.
we enumerate simple try catch blocks using sequences in flow services… If I want to throw an error in a child flow, so that the parent catches it and do error processing, I have to use “EXIT with signal FAILURE” option. This way the parent flow catches the child exception, and generates logging/email etc.
The only PROBLEM being any flow exits with signal FAILURE generates an email as if it was a service exception. The email goes to the person specified in watt.server.serviceMail, which is what I don’t want.
any way to circumvent it ?? A way, by which I can still exit from child flow as if an exception was thrown, and if such is caught in parent flow, doesn’t generate those annoying emails!!
If you dont want your service to fail but want the parent to be notified of the error you will have to use some kind of error message string. This can have both expected and unexpected error messages trapped and passed to the parent flow.
I use a java service called throwError which just throws a ServiceException constructed from an error message string. In the following code snippet an expected error from step 1.1.5 will be caught in the 1.2 SEQUENCE block and any unexpected errors in the 1.1 SEQUENCE block would also be caught in the 1.2 SEQUENCE block. This situation is ideal candidate for a throwError kind of service. If I use an EXIT from $parent with failure step at 1.1.5.1 control does go to 1.2 but getLastError does not retrieve the error message.
SEQUENCE (Exit on Success)
1.1 SEQUENCE (Exit on Failure)
1.1.1 Your flow steps here
1.1.2 …
1.1.3 …
1.1.4…
1.1.5 BRANCH (check for error condition)
1.1.5.1 throwError
1.1.6 More flow steps
1.1.7 …
1.1.8 …
1.2 SEQUENCE
1.2.1 getLastError
1.2.2 Assign lastError/error to a message string
1.2.3 Exit with success
Why dont you use return status variables instead of Exit with failure. For example in Child1 and Child2 you can replace the Exit steps with a MAP that just assigns the lastError/error to an errorMessage variable. In the next step exit from flow with success.
In the calling service just call the child and then check for the errorMessage variable. If it exists you know that there was a failure and you can take any actions. And you avoided an error email being generated as you did not exit with a failure.
Yes, you are right, and I dont want it that way !!
I mean if child1 say invokes child2;3;4;5 , then I have to do branch after each invokes to the childs. Which I think is lot of overhead for resources/developer.
I guess, I am looking for a another way to throw an error in a flow service apart from “exit $flow with signal Failure” (which generates those extra emails)
The only problem to overcome is that webMethods doesnt allow java services to throw Exceptions. (apart from Server.throwError way which is no useful to catch or nest exceptions in our scenerio)
Hence, I guess, I am still looking for a better error Handling framework.