diff --git a/app/assets/javascripts/editor/ajax.js b/app/assets/javascripts/editor/ajax.js index 971f75d6..127944f6 100644 --- a/app/assets/javascripts/editor/ajax.js +++ b/app/assets/javascripts/editor/ajax.js @@ -7,11 +7,12 @@ CodeOceanEditorAJAX = { }, ajaxError: function(response) { - var message = ((response || {}).responseJSON || {}).message || ''; + const responseJSON = ((response || {}).responseJSON || {}); + const message = responseJSON.message || responseJSON.error || ''; $.flash.danger({ text: message.length > 0 ? message : $('#flash').data('message-failure'), showPermanent: response.status === 422, }); } -}; \ No newline at end of file +}; diff --git a/app/assets/javascripts/exercises.js.erb b/app/assets/javascripts/exercises.js.erb index 5ffea543..e648d2fe 100644 --- a/app/assets/javascripts/exercises.js.erb +++ b/app/assets/javascripts/exercises.js.erb @@ -110,11 +110,14 @@ $(document).on('turbolinks:load', function () { } } - var ajaxError = function (error) { + var ajaxError = function (response) { + const responseJSON = ((response || {}).responseJSON || {}); + const message = responseJSON.message || responseJSON.error || ''; + $.flash.danger({ - text: $('#flash').data('message-failure') + text: message.length > 0 ? message : $('#flash').data('message-failure'), + showPermanent: response.status === 422, }); - Sentry.captureException(JSON.stringify(error)); }; var buildCheckboxes = function () { diff --git a/app/views/request_for_comments/show.html.slim b/app/views/request_for_comments/show.html.slim index 890d371c..b06cee5b 100644 --- a/app/views/request_for_comments/show.html.slim +++ b/app/views/request_for_comments/show.html.slim @@ -469,9 +469,11 @@ javascript: } function ajaxError(response) { - var message = ((response || {}).responseJSON || {}).message || ''; + const responseJSON = ((response || {}).responseJSON || {}); + const message = responseJSON.message || responseJSON.error || ''; $.flash.danger({ - text: message.length > 0 ? message : $('#flash').data('message-failure') + text: message.length > 0 ? message : $('#flash').data('message-failure'), + showPermanent: response.status === 422, }); }