How to get the line number in error in java?
===

I know that the line in error is `to_return = find(list,false);` How can I get the line number of this line when there is `NullPointerException` type of error? Or in line number in general?

I tried few things. The closest is this one `Called.getLineNumber()` which gives me the line number of `StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];`


	public TestObject[] myfind(Subitem list )throws Exception{
		TestObject[]to_return=null;
		try {
			to_return = find(list,false);
		}
		catch (RationalTestException ex) {
			//logStoreException(ex);
			StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];
			StackTraceElement Calling = new Throwable().fillInStackTrace().getStackTrace()[1];
			throw new Exception (this.add_debugging_info(Called, Calling, ex.getMessage()));

		} 	
		catch (NullPointerException npe) {
			StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];
			StackTraceElement Calling = new Throwable().fillInStackTrace().getStackTrace()[1];
			logStoreException(npe);
			System.out.println("Line number: "+npe.getStackTrace()[0].getLineNumber());	
			System.out.println("Line number2: "+Integer.toString(Called.getLineNumber()));
			System.out.println(this.add_debugging_info(Called, Calling, npe.getMessage()));
			throw new Exception (this.add_debugging_info(Called, Calling, npe.getMessage()));
		} 	
		catch (Exception ex) {
			StackTraceElement Called = new Throwable().fillInStackTrace().getStackTrace()[0];
			StackTraceElement Calling = new Throwable().fillInStackTrace().getStackTrace()[1];
			throw new Exception (this.add_debugging_info(Called, Calling, ex.getMessage()));

		} 
		finally {
			//unregisterAll();
			//unregister(to);
			return to_return;
		}
	}
