on 08-17-2009 7:57 AM
Hi all,
I am doing a java mapping for some scenario.
I want to throw a exception for some validations of field.
But in my code i used throw new RuntimeException(Message) which is not throwing an exception in runtime.
Is there some other way to throw the exception in runtime
Any solutions for this problem....
The problem is solved.
The exception is always thrown from the catch block of execute method.
Don't exit(n) anywhere in the code
Edited by: hlbabu123 on Aug 24, 2009 7:59 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
U need to throw exception in catch block of the execute method
because the exception ur java code is going to throw will be always catched in this catch block.
Never use any exit(n) in the code.
I think i made clear with my sentences,if u cannot follow still ,u just put the code u r using for throwing the exception
So that others can help u with it.
just use throw new RuntimeException(Message) dont use try and catch block.then it works fine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for ur answer..........
but in java mapping even if i call the exception
throw new RuntimeException(Message).... it is nt throwing the error....
i tried with
try
{
throw new RuntimeException(Message);
}
catch(Exception e)
{
throw new StreamTransformationException(Message,e);
}
also still i could not see any exception at all....
Hi,
the following blog will give you the clear idea about how to handle the Runtime Exception in Java Mapping
/people/prasannakrishna.mynam/blog/2009/07/21/handling-and-tracing-runtime-exceptions-in-java-mapping
Regards
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
I followed that blog but i could not trace out...
I have a function which will be called when ever there is validation fail
from that method i need to raise the exception..
void validationCheck(String Message)
{
try
{
int i=0;
i=i/i;
}
catch(Exception e)
{
throw new StreamTransformationException(Message,e);
}
so that i can create an exception which will come to catch and will throw the StreamTransformationException.... but still it is not
throwing the exception......
}
Any guess..........
Hi,
you have to use throw new RuntimeException(msg), in try block.
Ex:
void validationCheck(String Message)
{
try
{
int i=0;
i=i/i;
*throw new RuntimeException(Message);*
}
catch(Exception e)
{
throw new StreamTransformationException(Message,e);
}
You have to throw the Runtime Exception for the paticular Condition.
Regards
Venkat
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.