JDK-4074976 : Can't get Stack Trace into string easily; the only option is to print it.
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.1.2,1.1.5
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_2.5.1
  • CPU: generic,sparc
  • Submitted: 1997-08-28
  • Updated: 1998-04-15
  • Resolved: 1998-04-15
Related Reports
Duplicate :  
Relates :  
Description

Name: tb29552			Date: 08/27/97


company - Cornell University , email - ###@###.###

Hi, I was just noticing that the only way to get the
stack trace of an exception is to to do a
"PrintStackTrace" into a PrintStream.  I'm writing a
scientific application where I have some fear that some
section of the calculation might fail; execution is
controlled by a particular class which executes each
segment in try catch brackets -- when a calculation
blows up, it would be nice to be able to put as much of
the crash and burn record in with the data from the
calculation as possible; including the stack trace.
Prehaps I just don't want to write it to a PrintStream
-- I might want to preface the stack trace with comment
characters so it won't mess up the program I use to
interpret output files, for instance.

As such, I'd really like to have a way to put the stack
trace into a string -- this might be nice to have in
future versions of java.  I'm sure that other java
programmers face similar problems.

======================================================================

Comments
WORK AROUND Name: tb29552 Date: 08/27/97 I could make up a "OutputStream" which is fake and really puts anything wrote to it into a StringBuffer and then gives me a string with which I can do what I want. This is a waste of time and it's ugly. ======================================================================
11-06-2004

EVALUATION The user can hoop through wrapping a string buffer under a PrintStream and all that. But that is ugly. So I am accepting this. We can have a String Throwable.printStackTrace() but we cannot overload just on the return type in Java (correct?), so we might have to pick a good name for this. anand.palaniswamy@Eng 1997-11-05
05-11-1997