Exception - meaningless exception message

Guys please help

Whats with this code

import java.util.*;

publicclass ExcInMap{

static Map m;

publicstaticvoid main(String args[])throws Exception{

m =new HashMap();

m.put("st",new FancyException());

dummyCall();

}

staticvoid dummyCall()throws Exception{

Exception e =new FancyException();

throw (Exception)m.get("st");

}

}

class FancyExceptionextends Exception{

public String tostring(){

return"fancy became fantacy";

}

}

Output

Exception in thread "main" FancyException

at ExcInMap.main(ExcInMap.java:6)

I am wondering why from line 6 it shud be from line 11

Thanks in advance !

SanX

[1732 byte] By [SanXa] at [2007-10-2 16:57:22]
# 1
One correction please comment out line 10 i.eException e = new FancyException();that was put as for another test!ThanksSanX
SanXa at 2007-7-13 18:10:17 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

> I am wondering why from line 6 it shud be from line

> 11

>

> Thanks in advance !

> SanX

Because the stack trace information is put into the exception when it is created. So it has line 6. If you change dummyCall() to the following, you will get what you expect.Exception e = (Exception)m.get("st");

e.fillInStackTrace();

throw e;

atmguya at 2007-7-13 18:10:17 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
atmguy! Thanx! btw Do you see why did they code so, my friendz will be curious! It shud have been from the place of throw?SanX
SanXa at 2007-7-13 18:10:17 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4

> btw Do you see why did they code so, my friendz

> dz will be curious! It shud have been from the place

> of throw?

>

> SanX

I suppose it could have been designed such that the 'throw' automatically called fillInStackTrace(). In the code I have written and seen, a new Exception has always been created at the point where it is thrown. So there may be few times when an Exception needs to be created before it is thrown and it isn't worth the extra work to make 'throw' call fillInStackTrace().

atmguya at 2007-7-13 18:10:17 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...