From 1587214ea9d348118458528129759dcdae9cf46a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 28 Sep 2013 01:07:03 -0400 Subject: [PATCH] handle connection errors If we fail to connect, don't initialize mpc objects and such. Update the UI so the user can see that things are hosed. --- main.js | 8 +++++++- manifest.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 1687598..3ff3ca4 100644 --- a/main.js +++ b/main.js @@ -103,7 +103,12 @@ function mpc_connect(host, port) { update_ui('init'); tcpclient = new TcpClient(host, port); - tcpclient.connect(function() { + tcpclient.connect(function(resultCode) { + if (resultCode < 0) { + update_ui('error', resultCode); + return; + } + var mpc_sender = new TcpClientSender(tcpclient); tcpclient.addResponseListener(tramp_mpc_recv); mpc = new Mpc(mpc_sender, update_ui); @@ -301,6 +306,7 @@ function update_ui(state, cmd) { ui_mpc_status.innerText = ({ 'disconnect': 'Disconnecting...', 'init': 'Connecting...', + 'error': 'Connection error ' + cmd, })[state]; return; } diff --git a/manifest.json b/manifest.json index 1ec8ed4..762fcef 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "minimum_chrome_version": "24", "name": "Music Player Client", - "version": "3.1", + "version": "3.2", "description": "Control a Music Player Daemon (MPD)", "icons": { "128": "images/icon-128x128.png" -- 2.39.5