on 08-31-2006 10:15 AM
Hi
I am executing a try catch and i handled a exception in that but i want to stop further execution of the code in that action so how can we do that?
Is there anything like exit command?
Thanks
Ninad
Hi,
If you have handled an exception then you cannot stop the next set of instructions after the try-catch block to execute until and unless you are throwing a new exception from the catch block.
Another option can be having the try-catch block as the last instruction set.
There is no exit statement, but I think you can try firing an exit plug.
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satyajit
I am reporting a error from message pool in catchblock and after that i don't want to run the next code and i can't write that at the end of the action because of the logic.
Besicaly i am taking a string from input field and checking wheter it is a long or not. and passing the sting to next logic. I can't set Log attribute directly to Input Field becase of some client requirements. I am posting my code bellow so please tell me what more we can do with that.
try
{
String idocNum = wdContext.currentParametersElement().getIdocnumber();
if(idocNum!=null)
{
long tempIdoc = Long.valueOf(idocNum).longValue();
}
}
catch(NumberFormatException e)
{
IWDMessageManager msgManager= this.wdComponentAPI.getMessageManager();
IWDAttributeInfo attributeinfo = wdContext.nodeParameters().getNodeInfo().getAttribute("idocnumber");
msgManager.reportContextAttributeMessage(this.wdContext.currentParametersElement()
,attributeinfo
,IMessageDTCComp.NOT_INT
,null
,true
);
}
Thanks
Ninad
Hi Ninad,
I have modified your code a bit. Try this:
try
{
String idocNum = wdContext.currentParametersElement().getIdocnumber();
if(idocNum!=null)
{
long tempIdoc = Long.parseLong(idocNum);
}
}
catch(NumberFormatException e)
{
IWDMessageManager msgManager= this.wdComponentAPI.getMessageManager();
IWDAttributeInfo attributeinfo = wdContext.nodeParameters().getNodeInfo().getAttribute("idocnumber");
msgManager.reportContextAttributeMessage(this.wdContext.currentParametersElement()
,attributeinfo
,IMessageDTCComp.NOT_INT
,null
,true
);
return;
}
Regards,
Satyajit.
Hi,
when the error occurs in your try block it will automatically transfer the control to catch block. so the further codes won't be executed.
regards
karthik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.