Skip to main content

Where was this stacktrace printed?

3 replies [Last post]
Joined: 2003-06-17

I just spend hours finding the place where a
stacktrace was printed.

It would be nice if Throwable.printStackTrace() also
included a one line description where that stacktrace
was printed.

something like (see bottom line of stacktrace):
PlcException : Plc doesn't exist
at gti.plc.Plc.init (gti.plc.Plc:715)
at gti.init.Init.init (gti.init.Init:213)
printed at: gti.init.Init.init (gti.init.Init:225)

Kees Kuip

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-10-27

If PlcException is your own exception, you could override printStackTrace to call super.printStackTrace() and also include a statement about where you were being called from, e.g., by filling in the stack trace of a new Throwable. Note that for completeness you have to override

printStackTrace(PrintStream s)
printStackTrace(PrintWriter s)

There may well be other ways of getting this information (e.g., using debuggers or operating system specific tools).

Joined: 2004-06-03


I have this problem mostly with NullPointerException, so yes, a 1 line print about where the exception was printed (class, method, line number) would be very helpfull.

Joined: 2003-06-28