From b529c31fb44f1ae717a8cb430c8524ad680fa7d9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 2 Mar 2013 21:34:05 -0800 Subject: [PATCH] Add try/catch around error-throwing service calls. --- guacamole/src/main/webapp/scripts/admin-ui.js | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/admin-ui.js b/guacamole/src/main/webapp/scripts/admin-ui.js index ab131bced..ed66748b0 100644 --- a/guacamole/src/main/webapp/scripts/admin-ui.js +++ b/guacamole/src/main/webapp/scripts/admin-ui.js @@ -545,9 +545,19 @@ GuacAdmin.addUser = function(name) { // Delete user upon confirmation if (confirm("Are you sure you want to delete the user \"" + name + "\"?")) { - GuacamoleService.Users.remove(GuacAdmin.selected_user); - deselect(); - GuacAdmin.reset(); + + // Attempt to delete user + try { + GuacamoleService.Users.remove(GuacAdmin.selected_user); + deselect(); + GuacAdmin.reset(); + } + + // Alert on failure + catch (e) { + alert(e.message); + } + } }; @@ -815,9 +825,19 @@ GuacAdmin.addConnection = function(connection) { // Delete connection upon confirmation if (confirm("Are you sure you want to delete the connection \"" + connection.id + "\"?")) { - GuacamoleService.Connections.remove(GuacAdmin.selected_connection); - deselect(); - GuacAdmin.reset(); + + // Attempt to delete connection + try { + GuacamoleService.Connections.remove(GuacAdmin.selected_connection); + deselect(); + GuacAdmin.reset(); + } + + // Alert on failure + catch (e) { + alert(e.message); + } + } };