diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-03-25 16:35:57 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-03-30 13:09:29 +0200 |
commit | 5b03ea193c1927305fc99b93307b6c74bde0d84d (patch) | |
tree | 2a4e991e7ed7913d535e9b42c5daf6c91c9a68fa | |
parent | ba9d5eb671997a3a7b82eeb3eb04c0a3e5c3a966 (diff) |
Clean up a few error functions
-rw-r--r-- | js/codeq/change_password.js | 6 | ||||
-rw-r--r-- | js/codeq/profile.js | 11 | ||||
-rw-r--r-- | js/codeq/settings.js | 9 | ||||
-rw-r--r-- | js/codeq/signup.js | 7 |
4 files changed, 20 insertions, 13 deletions
diff --git a/js/codeq/change_password.js b/js/codeq/change_password.js index 8091a6d..4a050c3 100644 --- a/js/codeq/change_password.js +++ b/js/codeq/change_password.js @@ -54,8 +54,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ jqChangePassForm.find('.error.failed').show(); } }) - .fail(function (reason) { - alert('Password change failed: ' + reason); + .fail(function (error) { + var message = 'Changing password failed: ' + error.message; + codeq.log.error(message, error); + alert(message); }) .done(); } diff --git a/js/codeq/profile.js b/js/codeq/profile.js index 79a9bf5..8d26c85 100644 --- a/js/codeq/profile.js +++ b/js/codeq/profile.js @@ -44,7 +44,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ $('#disabled').css('display', 'none'); codeq.comms.getUserStat() .then(function (data) { - if (data.code !== 0) throw new Error('GetUserStat failed, code: ' + data.code + ', message: ' + data.message); + if (data.code !== 0) { + throw new Error(data.message); + } data = data.stat; var columns = ['language', 'problem_group', 'problems_count', 'done', 'in_progress'], @@ -74,9 +76,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ $('#profile-stats').html(items) }) - .fail(function (reason) { - codeq.log.error('GetUserStat failed: ' + reason, reason); - alert('GetUserStat failed: ' + reason); + .fail(function (error) { + var message = 'Could not retrieve stats: ' + error.message; + codeq.log.error(message, error); + alert(message); }) .done(); }, diff --git a/js/codeq/settings.js b/js/codeq/settings.js index e6b8fce..2a3d736 100644 --- a/js/codeq/settings.js +++ b/js/codeq/settings.js @@ -53,13 +53,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ codeq.comms.updateSettings(codeq.settings) .then(function (data) { if (data.code !== 0) { - throw new Error('Updating settings failed, code: ' + data.code + ', message: ' + data.message); + throw new Error(data.message); } history.back(); }) - .fail(function(reason){ - codeq.log.error('Settings update failed: ' + reason); - alert('Settings update failed: ' + reason); + .fail(function (error) { + var message = 'Updating settings failed: ' + error.message; + codeq.log.error(message, error); + alert(message); }) .done(); e.preventDefault(); diff --git a/js/codeq/signup.js b/js/codeq/signup.js index 7f28e9f..a0ac4de 100644 --- a/js/codeq/signup.js +++ b/js/codeq/signup.js @@ -77,9 +77,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ throw new Error(data.message); } }) - .fail(function (reason) { - codeq.log.error('Signup failed: ' + reason, reason); - alert('Signup failed: ' + reason); + .fail(function (error) { + var message = 'Signup failed: ' + error.message; + codeq.log.error(message, error); + alert(message); }) .done(); } |