From: Mike Frysinger Date: Sat, 28 Sep 2013 05:07:03 +0000 (-0400) Subject: handle connection errors X-Git-Tag: v3.2 X-Git-Url: https://git.wh0rd.org/?p=chrome-ext%2Fmusic-player-client.git;a=commitdiff_plain;h=1587214ea9d348118458528129759dcdae9cf46a;ds=inline 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. --- 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"