]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Friendly error messages for failed learns 756/head
authorAndrew Lewis <nerf@judo.za.org>
Tue, 26 Jul 2016 12:47:10 +0000 (14:47 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 26 Jul 2016 12:56:08 +0000 (14:56 +0200)
interface/js/rspamd.js

index 1aa96e6fab09c6d7c2bc89baf52afe9546a7a305..be73bf368cec2865c4c18c16b5caa5e83a879914 100644 (file)
                         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 = $('<a>').text(json.error).html();
+                    } catch(err) {
+                        var errorMsg = $('<a>').text("Error: [" + textStatus + "] " + errorThrown).html();
                     }
+                    alertMessage('alert-error', errorMsg);
                 }
             });
         }