mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Rework exceptions in the parsing / provider subsystem
This commit is contained in:
parent
4c42d0cd32
commit
083dac8b83
130 changed files with 504 additions and 342 deletions
|
@ -25,7 +25,6 @@ import java.util.Enumeration;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.StanzaCollector;
|
||||
|
@ -330,7 +329,7 @@ public class RTPBridge extends IQ {
|
|||
|
||||
@Override
|
||||
public RTPBridge parse(XmlPullParser parser, int initialDepth)
|
||||
throws SmackException, XmlPullParserException,
|
||||
throws XmlPullParserException,
|
||||
IOException {
|
||||
|
||||
boolean done = false;
|
||||
|
@ -339,7 +338,8 @@ public class RTPBridge extends IQ {
|
|||
String elementName;
|
||||
|
||||
if (!parser.getNamespace().equals(RTPBridge.NAMESPACE))
|
||||
throw new SmackException("Not a RTP Bridge packet");
|
||||
// TODO: Should be SmackParseException.
|
||||
throw new IOException("Not a RTP Bridge packet");
|
||||
|
||||
RTPBridge iq = new RTPBridge();
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public class STUN extends SimpleIQ {
|
|||
|
||||
@Override
|
||||
public STUN parse(XmlPullParser parser, int initialDepth)
|
||||
throws SmackException, XmlPullParserException,
|
||||
throws XmlPullParserException,
|
||||
IOException {
|
||||
|
||||
boolean done = false;
|
||||
|
@ -126,7 +126,7 @@ public class STUN extends SimpleIQ {
|
|||
String elementName;
|
||||
|
||||
if (!parser.getNamespace().equals(NAMESPACE))
|
||||
throw new SmackException("Not a STUN packet");
|
||||
throw new IOException("Not a STUN packet");
|
||||
|
||||
STUN iq = new STUN();
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.jingleold.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
|
||||
import org.jivesoftware.smackx.jingleold.media.PayloadType;
|
||||
|
@ -68,12 +67,11 @@ public abstract class JingleContentDescriptionProvider extends ExtensionElementP
|
|||
* @return a description element
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Override
|
||||
public JingleContentDescription parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
IOException {
|
||||
boolean done = false;
|
||||
JingleContentDescription desc = getInstance();
|
||||
|
||||
|
@ -85,7 +83,8 @@ public abstract class JingleContentDescriptionProvider extends ExtensionElementP
|
|||
if (name.equals(JingleContentDescription.JinglePayloadType.NODENAME)) {
|
||||
desc.addJinglePayloadType(parsePayload(parser));
|
||||
} else {
|
||||
throw new SmackException("Unknow element \"" + name + "\" in content.");
|
||||
// TODO: Should be SmackParseException.
|
||||
throw new IOException("Unknow element \"" + name + "\" in content.");
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (name.equals(JingleContentDescription.NODENAME)) {
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.jingleold.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
|
||||
import org.jivesoftware.smackx.jingleold.media.PayloadType;
|
||||
|
@ -67,12 +66,11 @@ public abstract class JingleDescriptionProvider extends ExtensionElementProvider
|
|||
* @param parser
|
||||
* the input to parse
|
||||
* @return a description element
|
||||
* @throws SmackException
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
@Override
|
||||
public JingleDescription parse(XmlPullParser parser, int initialDepth) throws SmackException, XmlPullParserException, IOException {
|
||||
public JingleDescription parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
JingleDescription desc = getInstance();
|
||||
|
||||
|
@ -84,7 +82,8 @@ public abstract class JingleDescriptionProvider extends ExtensionElementProvider
|
|||
if (name.equals(PayloadType.NODENAME)) {
|
||||
desc.addPayloadType(parsePayload(parser));
|
||||
} else {
|
||||
throw new SmackException("Unknow element \"" + name + "\" in content.");
|
||||
// TODO: Should be SmackParseException.
|
||||
throw new IOException("Unknow element \"" + name + "\" in content.");
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (name.equals(JingleDescription.NODENAME)) {
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
package org.jivesoftware.smackx.jingleold.provider;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
@ -31,6 +33,7 @@ import org.jivesoftware.smackx.jingleold.packet.JingleTransport;
|
|||
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The JingleProvider parses Jingle packets.
|
||||
|
@ -41,11 +44,12 @@ public class JingleProvider extends IQProvider<Jingle> {
|
|||
|
||||
/**
|
||||
* Parse a iq/jingle element.
|
||||
* @throws Exception
|
||||
* @throws ParseException
|
||||
* @throws XmlPullParserException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public Jingle parse(XmlPullParser parser, int intialDepth)
|
||||
throws Exception {
|
||||
public Jingle parse(XmlPullParser parser, int intialDepth) throws IOException, XmlPullParserException, ParseException {
|
||||
|
||||
Jingle jingle = new Jingle();
|
||||
String sid = "";
|
||||
|
@ -103,12 +107,14 @@ public class JingleProvider extends IQProvider<Jingle> {
|
|||
} else if (namespace.equals(JingleTransport.Ice.NAMESPACE)) {
|
||||
currentContent.addJingleTransport(jtpIce.parse(parser));
|
||||
} else {
|
||||
throw new SmackException("Unknown transport namespace \"" + namespace + "\" in Jingle packet.");
|
||||
// TODO: Should be SmackParseException.
|
||||
throw new IOException("Unknown transport namespace \"" + namespace + "\" in Jingle packet.");
|
||||
}
|
||||
} else if (namespace.equals(JingleContentInfo.Audio.NAMESPACE)) {
|
||||
jingle.setContentInfo((JingleContentInfo) jmipAudio.parse(parser));
|
||||
} else {
|
||||
throw new SmackException("Unknown combination of namespace \"" + namespace + "\" and element name \""
|
||||
// TODO: Should be SmackParseException.
|
||||
throw new IOException("Unknown combination of namespace \"" + namespace + "\" and element name \""
|
||||
+ elementName + "\" in Jingle packet.");
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.jingleold.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
|
||||
import org.jivesoftware.smackx.jingleold.nat.ICECandidate;
|
||||
|
@ -52,10 +51,9 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
|
|||
* @return a transport element.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Override
|
||||
public JingleTransport parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
public JingleTransport parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
JingleTransport trans = getInstance();
|
||||
|
||||
|
@ -69,7 +67,8 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
|
|||
if (jtc != null) trans.addCandidate(jtc);
|
||||
}
|
||||
else {
|
||||
throw new SmackException("Unknown tag \"" + name + "\" in transport element.");
|
||||
// TODO: Should be SmackParseException.
|
||||
throw new IOException("Unknown tag \"" + name + "\" in transport element.");
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue