changeset 32:b15e1581c3d4

Allow iq error to not have a <text/>.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 23 Dec 2018 20:08:40 +0100
parents e561bdd81777
children 038cab68fa3a
files util.js vcard.js
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/util.js
+++ b/util.js
@@ -62,9 +62,11 @@ function parseErrorIq(iq) {
     if (condition.namespaceURI !== 'urn:ietf:params:xml:ns:xmpp-stanzas')
         return null;
     const text = error.lastChild;
+    if (text === condition)
+        return condition.localName;
     if (text.namespaceURI !== 'urn:ietf:params:xml:ns:xmpp-stanzas' || text.localName !== 'text')
         return null;
-    return [condition.localName, text.textContent];
+    return condition.localName + ': ' + text.textContent;
 }
 
 function displaySpinner(spinner) {
--- a/vcard.js
+++ b/vcard.js
@@ -42,8 +42,7 @@ function initVCard(connection) {
     function onVCard4RetrievalError(iq, string)
     {
         if (!string) {
-            const [condition, text] = parseErrorIq(iq);
-            const string = condition + ': ' + text;
+            string = parseErrorIq(iq);
         }
         string = 'Failed to retrieve vCard4: ' + string;
         console.log(string);
@@ -82,8 +81,8 @@ function initVCard(connection) {
 
     function onVCard4ChangeError(iq)
     {
-        const [condition, text] = parseErrorIq(iq);
-        const string = 'Failed to set vCard4: ' + condition + ': ' + text;
+        const string = parseErrorIq(iq);
+        const string = 'Failed to set vCard4: ' + string;
         console.log(string);
         spinnerError(spinner_img, string);
     }