mcgilman commented on a change in pull request #3401: NIFI-6160 NIFI-6170 Apply
config error handling convention
URL: https://github.com/apache/nifi/pull/3401#discussion_r274508453
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-error-handler.js
##########
@@ -142,6 +142,36 @@
// show the error pane
$('#message-pane').show();
}
+ },
+
+ /**
+ * Method for handling ajax errors when submitting configuration
update (PUT/POST) requests.
+ * In addition to what handleAjaxError does, this function splits
+ * the error message text to display them as an unordered list.
+ *
+ * @argument {object} xhr The XmlHttpRequest
+ * @argument {string} status The status of the request
+ * @argument {string} error The error
+ */
+ handleConfigurationUpdateAjaxError: function (xhr, status, error) {
+ if (xhr.status === 400) {
+ var errors = xhr.responseText.split('\n');
+
+ var content;
+ if (errors.length === 1) {
+ content = $('<span></span>').text(errors[0]);
+ } else {
+ content = nfCommon.formatUnorderedList(errors);
+ }
+
+ nfDialog.showOkDialog({
+ dialogContent: content,
+ headerText: 'Configuration Error'
+ });
+ } else {
+ self.handleAjaxError(xhr, status, error);
Review comment:
The idea is the error handler is to simply show a dialog when the error is
something that is expected and where we want the user to be able to continue
using the application. When the error is not expected (like a 500 response
code) or we do not want the user to attempt another request (like the user is
not authenticated) we hide the canvas by showing the `message-pane`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services