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

Merge pull request #303 from adiaholic/SMACK-839

Generic Exception replaced with Type Specific Exceptions.
This commit is contained in:
Florian Schmaus 2019-05-20 09:44:04 +02:00 committed by GitHub
commit e8d9aed4be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -1251,7 +1251,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
try {
stanza = PacketParserUtils.parseStanza(parser, incomingStreamXmlEnvironment);
}
catch (Exception e) {
catch (XmlPullParserException | SmackParsingException | IOException e) {
CharSequence content = PacketParserUtils.parseContentDepth(parser,
parserDepth);
UnparseableStanza message = new UnparseableStanza(content, e);

View file

@ -55,6 +55,7 @@ import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jxmpp.jid.Jid;
import org.jxmpp.stringprep.XmppStringprepException;
/**
* Utility class that helps to parse packets. Any parsing packets method that must be shared
@ -89,7 +90,7 @@ public class PacketParserUtils {
}
@SuppressWarnings("unchecked")
public static <S extends Stanza> S parseStanza(String stanza) throws Exception {
public static <S extends Stanza> S parseStanza(String stanza) throws XmlPullParserException, SmackParsingException, IOException {
return (S) parseStanza(getParserFor(stanza), null);
}
@ -101,9 +102,11 @@ public class PacketParserUtils {
* @param parser
* @param outerXmlEnvironment the outer XML environment (optional).
* @return a stanza which is either a Message, IQ or Presence.
* @throws Exception
* @throws XmlPullParserException
* @throws SmackParsingException
* @throws IOException
*/
public static Stanza parseStanza(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception {
public static Stanza parseStanza(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, SmackParsingException, IOException {
ParserUtils.assertAtStartTag(parser);
final String name = parser.getName();
switch (name) {
@ -508,9 +511,12 @@ public class PacketParserUtils {
* @param parser the XML parser, positioned at the start of an IQ packet.
* @param outerXmlEnvironment the outer XML environment (optional).
* @return an IQ object.
* @throws Exception
* @throws XmlPullParserException
* @throws XmppStringprepException
* @throws IOException
* @throws SmackParsingException
*/
public static IQ parseIQ(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception {
public static IQ parseIQ(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, XmppStringprepException, IOException, SmackParsingException {
ParserUtils.assertAtStartTag(parser);
final int initialDepth = parser.getDepth();
XmlEnvironment iqXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);