toString()

Format

exception information, including the exception type and text, to a string.

Syntax

String toString()
 

Parameters

exception
The variable holding an exception object.

Notes

The toString() method formats the exception information for the current exception as follows:

exceptionType: messageText
 

In the line above, exceptionType is the exception object's exception type and messageText is its exception text.

Note:
You can use the getMessage() method to retrieve only the exception text from the current exception.

Examples

The following example writes the current exception information to the String variable newmessage:

String newmessage = currentException.toString();
 

Copyright IBM Corp. 2003, 2004