From 13cdb96ede3b876f8720eae0e677e490f52812aa Mon Sep 17 00:00:00 2001 From: Darren Date: Mon, 20 May 2013 14:37:23 +0100 Subject: [PATCH] More connection errors now displayed --- client/assets/dev/model_newconnection.js | 5 +++++ client/assets/dev/view.js | 21 +++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/client/assets/dev/model_newconnection.js b/client/assets/dev/model_newconnection.js index 368f8bf..5bf64ca 100644 --- a/client/assets/dev/model_newconnection.js +++ b/client/assets/dev/model_newconnection.js @@ -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, diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index d5dce46..1a763af 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -379,8 +379,25 @@ _kiwi.view.ServerSelect = function () { } }, - showError: function (event) { - this.setStatus('Error connecting', 'error'); + showError: function (error_reason) { + var err_text = 'Error Connecting'; + + if (error_reason) { + switch (error_reason) { + case 'ENOTFOUND': + err_text = 'Server not found'; + break; + + case 'ECONNREFUSED': + err_text += ' (Connection refused)'; + break; + + default: + err_text += ' (' + error_reason + ')'; + } + } + + this.setStatus(err_text, 'error'); $('button', this.$el).attr('disabled', null); this.show(); } -- 2.25.1