1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 22:12:05 +01:00

Fixes an error while parsing an error message with another format

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2160 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2003-11-05 16:47:32 +00:00 committed by gdombiak
parent 7f2753f78d
commit d9aa18a34c

View file

@ -617,16 +617,22 @@ class PacketReader {
*/ */
private XMPPError parseError(XmlPullParser parser) throws Exception { private XMPPError parseError(XmlPullParser parser) throws Exception {
String errorCode = null; String errorCode = null;
String message = null;
for (int i=0; i<parser.getAttributeCount(); i++) { for (int i=0; i<parser.getAttributeCount(); i++) {
if (parser.getAttributeName(i).equals("code")) { if (parser.getAttributeName(i).equals("code")) {
errorCode = parser.getAttributeValue("", "code"); errorCode = parser.getAttributeValue("", "code");
} }
} }
String message = parser.nextText(); // Get the error text in a safe way since we are not sure about the error message format
try {
message = parser.nextText();
}
catch (XmlPullParserException ex) {}
while (true) { while (true) {
if (parser.getEventType() == XmlPullParser.END_TAG && parser.getName().equals("error")) { if (parser.getEventType() == XmlPullParser.END_TAG && parser.getName().equals("error")) {
break; break;
} }
parser.next();
} }
return new XMPPError(Integer.parseInt(errorCode), message); return new XMPPError(Integer.parseInt(errorCode), message);
} }