From e7089c55ac72f716e17203a9b8732b2b5c82c150 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Mon, 22 Aug 2016 21:30:57 +0200 Subject: Improved error handling for httpupload --- .../conversationsplus/xmpp/httpupload/SlotPacketParser.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java index 0630449a..655d8759 100644 --- a/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java +++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java @@ -1,27 +1,30 @@ package de.thedevstack.conversationsplus.xmpp.httpupload; import de.thedevstack.conversationsplus.xml.Element; -import de.thedevstack.conversationsplus.xmpp.AbstractIqPacketParser; +import de.thedevstack.conversationsplus.xmpp.IqPacketParser; import de.thedevstack.conversationsplus.xmpp.exceptions.UnexpectedIqPacketTypeException; import de.thedevstack.conversationsplus.xmpp.exceptions.XmppException; import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket; +import de.thedevstack.conversationsplus.xmpp.utils.ErrorIqPacketExceptionHelper; /** * */ -public final class SlotPacketParser extends AbstractIqPacketParser { +public final class SlotPacketParser extends IqPacketParser { public static HttpUploadSlot parseGetAndPutUrl(IqPacket packet) throws XmppException { + HttpUploadSlot httpUploadSlot = null; if (packet.getType() == IqPacket.TYPE.RESULT) { Element slot = findRequiredChild(packet, "slot", HttpUpload.NAMESPACE); String getUrl = findRequiredChildContent(slot, "get"); String putUrl = findRequiredChildContent(slot, "put"); - return new HttpUploadSlot(getUrl, putUrl); + httpUploadSlot = new HttpUploadSlot(getUrl, putUrl); } else if (packet.getType() == IqPacket.TYPE.ERROR) { - throw new XmppException(); // Do proper handling of error cases + ErrorIqPacketExceptionHelper.throwIqErrorException(packet); } else { throw new UnexpectedIqPacketTypeException(packet, packet.getType(), IqPacket.TYPE.RESULT, IqPacket.TYPE.ERROR); } + return httpUploadSlot; } } -- cgit v1.2.3