Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Get error line from java code

hello All,

 

I am looking for one help, for example, I have tjavarow component and I am writing a piece of code suppose 500 lines of code. If some error occurs, like, Null pointer exception, I am not understanding where/on which line is failing.

I want to print the code line where error occurred. How to print that code line?

Labels (3)
7 Replies
Jesperrekuh
Specialist

implement this code :

try{
//your crazy stuff

}catch (Exception e){
.... e.getLineNumber();
}

should do the trick, adjust for your own way.

Anonymous
Not applicable
Author

@Dijke I don't want line number, I can get thru StackTrace as well. I am looking for the help, where I will get code which causes failure.

 

Is there any way get the code which causes failure.

 

e.g. If you get null pointer exception or some other error, then you can't figure out which column having issue and where it is failing in custom code. 

Jesperrekuh
Specialist

I doubt its possible... it has to do with java OO and compiler kernel mem allocation.

So within components like tMap they incorporate by catching these nullpointers. 
try and catch ... is the way to do things in java.  Java Exception class

There's something with HashMap in the Exception class, but never used it... I assume something with keep track of memallocation... but no idea!

Would love to hear if you succeed... 


Good Luck!

David_Beaty
Specialist

Slightly off topic, but I'd say putting 500 lines of java code in a tJavaRow wasnt a good idea. Consider putting in to a Code routine.

 

Thanks

 

David

Anonymous
Not applicable
Author

@dsoulalioux, I am already using the code routine. but I have suppose 150 columns and implementing some transformation which I can't write in routine, so it is coming like 500+ lines, so my intention is that is any error occurs get that code line and print, so it will be easy to debug and fix the error.

Is there any way I am looking for.

Anonymous
Not applicable
Author

@dsoulalioux I am already using the code routine. but I have suppose 150 columns and implementing some transformation which I can't write in routine, so it is coming like 500+ lines, so my intention is that is any error occurs get that code line and print, so it will be easy to debug and fix the error.

Is there any way I am looking for.

David_Beaty
Specialist

As @Dijke I don't think its really possible. The only (painful) way I can think of is to encapsulate each transformations as a separate try/catch section where you can also capture the column name in question.