I would like to : exit and signal failure in a java service.
Any one knows how to do that in java instead of flow?
Thanks
I would like to : exit and signal failure in a java service.
Any one knows how to do that in java instead of flow?
Thanks
//throwing exception in an if-then-else block
if (<some condition>) {
//do stuff
} else {
throw new ServiceException("Some error occurred: <details>");
}
//throwing exception in try-catch block
try {
//do stuff that might cause exception
} catch (Exception ex) { //use generic Exception or more specific one
throw new ServiceException("Some exception occured: " + ex);
}
Thanks but are you sure this works?
I have this now but no exit and signal failure
message = "Error:SyntaxCheck................... ";
try {
Values vv = new Values ();
vv.put ("message", message);
vv.put ("function", "LOGOP");
vv.put ("level", 4);
Service.doInvoke ("pub.flow", "debugLog", vv);
} catch (Exception elog) { throw new ServiceException (message );}
What precisely are you seeing? And what do you expect to happen?
my message is written in the serverlog, thats all I see
when I use the flow commands EXIT with the option “signal failure”
then control goes to the catch block, that good.
but there fore I have to add a branch and an exit command after my java service.
I do not think that is elegant, I rather would like to
program the functionality: “exit with signal failure” as java statements so I do not have to add 2 flow commands after my java service.
I added a screenShot as an attachmant, not sure how you can get it
Perhaps you would find the ExceptionHandling examples in the WmSamples package useful. Starting with IS 6.5, you have to download that package from Advantage.
Mark
This conversation is a bit muddled, but i think that gerarddoets is looking for something a bit odd.
gerarddoets, if you want it to always signal failure and exit, try this:
message = "Error:SyntaxCheck… ";
Values vv = new Values ();
vv.put (“message”, message);
vv.put (“function”, “LOGOP”);
vv.put (“level”, 4);
Service.doInvoke (“pub.flow”, “debugLog”, vv);
throw new ServiceException (message );
Good luck, i may not be understanding exactly what you are trying to do. Give it a try, if it does what you want, great! If not, let us know more details about what you are trying to accomplish.
Thanks!
-greg
“but there fore I have to add a branch and an exit command after my java service”
Your branch and exit flow and signal failure are never executed because the testGerard step is throwing an exception and exiting your FLOW service right then and there.
Calling a Java service is no different than calling any other service (FLOW or Java). If the service can throw an exception, and you want to catch it, use a try/catch structure.
SEQUENCE (Exit on SUCCESS)
…SEQUENCE (Exit on FAILURE)
…testGerard (may throw ServiceException)
…SEQUENCE (Exit on DONE)
…pub.flow:getLastError (lastError holds ServiceException info)
…(do anything else)
Given the Java code snippet you posted, I have to ask why you’re writing a Java service? Can what you’re doing in Java be done using FLOW?
at first I did not see your mods but after then,
works fine now
Thx