
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
implement this code :
try{
//your crazy stuff
}catch (Exception e){
.... e.getLineNumber();
}
should do the trick, adjust for your own way.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
