diff sat_pubsub/gateway.py @ 274:6641ea7990ee

Fix checking for malformed XMPP URI in DeleteResource.
author Ralph Meijer <ralphm@ik.nu>
date Mon, 07 Oct 2013 12:14:54 +0200
parents 6ba0d6def7f5
children 9c74cd2635f6
line wrap: on
line diff
--- a/sat_pubsub/gateway.py	Sun Jan 20 13:38:41 2013 +0100
+++ b/sat_pubsub/gateway.py	Mon Oct 07 12:14:54 2013 +0200
@@ -238,15 +238,14 @@
             failure.trap(error.NodeNotFound)
             raise Error(http.NOT_FOUND, "Node not found")
 
-        def trapXMPPURIParseError(failure):
-            failure.trap(XMPPURIParseError)
-            raise Error(http.BAD_REQUEST,
-                        "Malformed XMPP URI: %s" % failure.value)
-
         if not request.args.get('uri'):
             raise Error(http.BAD_REQUEST, "No URI given")
 
-        jid, nodeIdentifier = getServiceAndNode(request.args['uri'][0])
+        try:
+            jid, nodeIdentifier = getServiceAndNode(request.args['uri'][0])
+        except XMPPURIParseError, e:
+            raise Error(http.BAD_REQUEST, "Malformed XMPP URI: %s" % e)
+
 
         data = request.content.read()
         if data:
@@ -259,7 +258,6 @@
                                     redirectURI)
         d.addCallback(toResponse)
         d.addErrback(trapNotFound)
-        d.addErrback(trapXMPPURIParseError)
         return d