From: Andrew Lewis Date: Tue, 26 Jul 2016 12:47:10 +0000 (+0200) Subject: [WebUI] Friendly error messages for failed learns X-Git-Tag: 1.3.1~54^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5570afeb035045efb74b8f87dd4e7ec9bc753888;p=rspamd.git [WebUI] Friendly error messages for failed learns --- diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index 1aa96e6fa..be73bf368 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -737,16 +737,14 @@ alertMessage('alert-success', 'Data successfully uploaded'); } }, - // error: function() { - // alertMessage('alert-error', 'Cannot upload data'); - // }, - statusCode: { - 404: function () { - alertMessage('alert-error', 'Cannot upload data, no server found'); - }, - 503: function () { - alertMessage('alert-error', 'Cannot tokenize message, no text data'); + error: function (xhr, textStatus, errorThrown) { + try { + var json = $.parseJSON(xhr.responseText); + var errorMsg = $('').text(json.error).html(); + } catch(err) { + var errorMsg = $('').text("Error: [" + textStatus + "] " + errorThrown).html(); } + alertMessage('alert-error', errorMsg); } }); }