ijokarumawak 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_r275188185
##########
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:
Addressed this by extracting the actions to disable the canvas from
`handleAjaxError` to a new function called `disableCanvas` in
`nf-canvas-error-handler.js`, so that both `handleAjaxError` and
`handleConfigurationUpdateAjaxError` can use it.
----------------------------------------------------------------
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