[enh] Use a more generic API error handler.

This commit is contained in:
opi 2015-11-15 17:13:44 +01:00
parent d442f8fc82
commit ad3b0c230c
3 changed files with 3 additions and 11 deletions

File diff suppressed because one or more lines are too long

View file

@ -146,12 +146,6 @@ var app = Sammy('#main', function (sam) {
if (xhr.status == 200) {
// Fail with 200, WTF
callback({});
} else if (xhr.status == 404) {
// API's 404 are not JSON, we can't use raw responseJSON
// and responseText is a complete HTML document.
c.flash('fail', y18n.t('uri_not_found', [uri]));
// Redirect to previous page.
c.redirect(store.get('path-1'));
} else if (xhr.status == 401) {
if (uri === '/login') {
c.flash('fail', y18n.t('wrong_password'));
@ -162,7 +156,7 @@ var app = Sammy('#main', function (sam) {
} else if (typeof xhr.responseJSON !== 'undefined') {
c.flash('fail', xhr.responseJSON.error);
} else if (typeof xhr.statusText !== 'undefined' && uri !== '/postinstall') {
c.flash('fail', xhr.statusText);
c.flash('fail', y18n.t('api_not_responding', [xhr.status+' '+xhr.statusText]));
} else {
if (uri === '/postinstall') {
if (installing) {

View file

@ -63,7 +63,6 @@
"unknown_argument" : "Unknown argument : %s",
"api_not_responding" : "API is not responding (Error : %s)",
"error_retrieve_feed" : "Could not retrieve feed : %s",
"uri_not_found" : "Page not found : %s",
"confirm_delete" : "Are you sure you want to delete %s ?",
"confirm_change_maindomain" : "Are you sure you want to change the main domain ?",