-
Bug
-
Resolution: Fixed
-
P3
-
6u14
-
h1180
-
generic
-
generic
-
Verified
SAXParseException retains a very useful information regarding where the error occurred, yet this information is not displayed unless the caller specifically looks for SAXParseException and prints it. This is especially problematic when SAXParseException shows up in a nested exception of an exception chaining.
To fix this, SAXParseException should implement the toString() method that returns a reasonable String representation of all the information that it holds. Something like:
public String toString() {
StringBuilder buf = new StringBuilder(getClass().getName());
String message = getLocalizedMessage();
if (message!=null) buf.append(": ").append(message);
if (publicId!=null) buf.append(":publicId=").append(publicId);
if (systemId!=null) buf.append(":systemId=").append(publicId);
if (lineNumber!=-1) buf.append(":lineNumber=").append(lineNumber);
if (columnNumber!=-1) buf.append(":columnNumber=").append(columnNumber);
return buf.toString();
}
This change doesn't affect the signature, so the spec revision is not necessary.
To fix this, SAXParseException should implement the toString() method that returns a reasonable String representation of all the information that it holds. Something like:
public String toString() {
StringBuilder buf = new StringBuilder(getClass().getName());
String message = getLocalizedMessage();
if (message!=null) buf.append(": ").append(message);
if (publicId!=null) buf.append(":publicId=").append(publicId);
if (systemId!=null) buf.append(":systemId=").append(publicId);
if (lineNumber!=-1) buf.append(":lineNumber=").append(lineNumber);
if (columnNumber!=-1) buf.append(":columnNumber=").append(columnNumber);
return buf.toString();
}
This change doesn't affect the signature, so the spec revision is not necessary.