Commit 1609305f authored by Ziassan's avatar Ziassan

close #229

Handling non-standardized errors Translated messages related to that If changing a setting isn't validated, the old value is put back in the field & put on focus
parent f00cbc81
Pipeline #805 failed with stages
in 4 minutes 9 seconds
......@@ -181,6 +181,8 @@
"GOTO_PLAYING": "Go to the kara currently playing",
"GOTO_BOTTOM": "Go to the end of the playlist",
"ERROR": "Error",
"UNKNOWN_ERROR": "Something wrong happened. Here's the message : ",
"UNAUTHORIZED": "Access forbidden. Your role doesn't permit this action",
"PL_LIST_ERROR": "Unable to display playlists",
"PL_CREATE_ERROR": "Unable to create playlist %s",
"PL_CREATED": "Playlist %s created",
......
......@@ -162,6 +162,8 @@
"ENGINEDISPLAYCONNECTIONINFOMESSAGE": "Message",
"ENGINEDISPLAYCONNECTIONINFO": "Afficher les infos du réseau",
"ERROR": "Erreur",
"UNKNOWN_ERROR": "Une erreur fortuite s'est produite : ",
"UNAUTHORIZED": "Accès défendu. Votre role n'est pas suffisant pour cette action.",
"PL_LIST_ERROR": "Impossible d'afficher les liste de lectures",
"PL_CREATE_ERROR": "Impossible de créer la liste de lecture %s",
"PL_CREATED": "Liste de lecture %s crée",
......
......@@ -457,6 +457,7 @@ var mouseDown; // Boolean : capture if the mouse is pressed
return promise.promise();
};
/* el is the html element containing the value being updated */
setSettings = function (el, changeAdminPass) {
// DEBUG && console.log( $(e).attr('name'), $(e).val(), $(e));
if (el.attr('oldValue') !== el.val() || el.attr('type') === 'checkbox') {
......@@ -494,6 +495,7 @@ var mouseDown; // Boolean : capture if the mouse is pressed
}
}).fail(function () {
if (changeAdminPass) { passwordUpdating.resolve(); }
el.val(el.attr('oldValue')).focus();
});
});
}
......
......@@ -127,17 +127,20 @@ var settingsNotUpdated;
console.log(res.status + ' - ' + textStatus + ' - ' + errorThrown + (res.responseJSON ? ' : ' + res.responseJSON.message : ''));
if(res.status != 0 && res.status != 200) {
var errMessage = 'unknown';
if(res.responseJSON.code) {
var code = '';
if(res.status == 500 && res.responseJSON.code) {
// var args = res.responseJSON.args;
var args = typeof res.responseJSON.args === 'object' ? Object.keys(res.responseJSON.args).map(function(e) {
return res.responseJSON.args[e];
}) : [ res.responseJSON.args];
errMessage = i18n.__(res.responseJSON.code, args);
} else if(res.status == 401) {
errMessage = i18n.__('UNAUTHORIZED');
} else {
errMessage = res.responseJSON.message;
code = i18n.__('UNKNOWN_ERROR');
errMessage = res.responseText;
}
//var code = softErrorMessage.indexOf(res.responseJSON.code) === -1 ? res.responseJSON.code + ' :' : '';
var code = '';
displayMessage('warning', code, errMessage);
}
}
......@@ -502,6 +505,7 @@ var settingsNotUpdated;
'BLCTYPE_7',
'BLCTYPE_8'];
/* list of error code allowing a iinfo popup message on screen */
showInfoMessage = [
'PL_SONG_ADDED',
'PL_SONG_DELETED',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment