More connection errors now displayed
authorDarren <darren@Darrens-MacBook-Pro.local>
Mon, 20 May 2013 13:37:23 +0000 (14:37 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Mon, 20 May 2013 13:37:23 +0000 (14:37 +0100)
client/assets/dev/model_newconnection.js
client/assets/dev/view.js

index 368f8bf60f0f286cad351f42119549fbef6d4fc9..5bf64cab596182ff4aa812543f3684c286501b54 100644 (file)
@@ -63,6 +63,11 @@ _kiwi.model.NewConnection = Backbone.Collection.extend({
 
 
     onNewNetwork: function(err, network) {
+        // Show any errors if given
+        if (err) {
+            this.view.showError(err);
+        }
+
         if (network && this.connect_details) {
             network.auto_join = {
                 channel: this.connect_details.channel,
index d5dce4616acbd2d1473ab10d727a5db3828ac436..1a763af5cd5c3f8e7ba21104c188c9c8af0356ae 100644 (file)
@@ -379,8 +379,25 @@ _kiwi.view.ServerSelect = function () {
             }\r
         },\r
 \r
-        showError: function (event) {\r
-            this.setStatus('Error connecting', 'error');\r
+        showError: function (error_reason) {\r
+            var err_text = 'Error Connecting';\r
+\r
+            if (error_reason) {\r
+                switch (error_reason) {\r
+                case 'ENOTFOUND':\r
+                    err_text = 'Server not found';\r
+                    break;\r
+\r
+                case 'ECONNREFUSED':\r
+                    err_text += ' (Connection refused)';\r
+                    break;\r
+\r
+                default:\r
+                    err_text += ' (' + error_reason + ')';\r
+                }\r
+            }\r
+\r
+            this.setStatus(err_text, 'error');\r
             $('button', this.$el).attr('disabled', null);\r
             this.show();\r
         }\r