[Profile indicator] Show '?' when an error occurs

Before, when something went wrong the profile indicator kept blinking
and nothing happened. This makes it clearer that the extension could not
retrieve the post count.

Change-Id: I3c85c01efad42e76ac7f93b453cdc74c5157de65
diff --git a/src/injections/profileindicator_inject.js b/src/injections/profileindicator_inject.js
index 0af5539..ddf1cfe 100644
--- a/src/injections/profileindicator_inject.js
+++ b/src/injections/profileindicator_inject.js
@@ -163,6 +163,14 @@
   return numPostsContainer;
 }
 
+// Set the badge text
+function setNumPostsBadge(badge, text) {
+  badge.classList.remove('num-posts-indicator--loading');
+  badge.querySelector('span').classList.remove(
+      'num-posts-indicator--num--loading');
+  badge.querySelector('span').textContent = text;
+}
+
 // Get options and then handle all the indicators
 function getOptionsAndHandleIndicators(sourceNode, isCC) {
   contentScriptRequest.sendRequest({'action': 'getProfileIndicatorOptions'})
@@ -252,20 +260,16 @@
                   }
                 }
 
-                numPostsContainer.classList.remove(
-                    'num-posts-indicator--loading');
-                numPostsContainer.querySelector('span').classList.remove(
-                    'num-posts-indicator--num--loading');
-                numPostsContainer.querySelector('span').textContent = numPosts;
+                setNumPostsBadge(numPostsContainer, numPosts);
               })
               .catch(
                   err => console.error('[opindicator] Unexpected error.', err));
         })
-        .catch(
-            err => console.error(
-                '[opindicator] Unexpected error. Couldn\'t load profile.',
-                err));
-    ;
+        .catch(err => {
+          console.error(
+              '[opindicator] Unexpected error. Couldn\'t load profile.', err);
+          setNumPostsBadge(numPostsContainer, '?');
+        });
   }
 
   if (options.indicatorDot) {