Better error handling/reporting in project creation

This commit is contained in:
Nick O'Leary
2018-02-05 15:59:11 +00:00
parent 9f7dd7f5d4
commit 5fe5db603d
6 changed files with 79 additions and 54 deletions

View File

@@ -143,7 +143,8 @@ RED.projects.settings = (function() {
RED.sidebar.versionControl.refresh(true);
},
400: {
'unexpected_error': function(error) {
'*': function(error) {
utils.reportUnexpectedError(error);
done(error,null);
}
},
@@ -208,7 +209,8 @@ RED.projects.settings = (function() {
done(null,data);
},
400: {
'unexpected_error': function(error) {
'*': function(error) {
utils.reportUnexpectedError(error);
done(error,null);
}
},
@@ -962,7 +964,7 @@ RED.projects.settings = (function() {
var done = function(err) {
spinner.remove();
if (err) {
console.log(err);
utils.reportUnexpectedError(err);
return;
}
flowFileLabelText.text(flowFileInput.val());
@@ -1005,10 +1007,6 @@ RED.projects.settings = (function() {
'credentials_load_failed': function(error) {
done(error);
},
'unexpected_error': function(error) {
console.log(error);
done(error);
},
'missing_current_credential_key': function(error) {
credentialSecretExistingInput.addClass("input-error");
popover = RED.popover.create({
@@ -1019,6 +1017,9 @@ RED.projects.settings = (function() {
autoClose: 3000
}).open();
done(error);
},
'*': function(error) {
done(error);
}
},
}
@@ -1142,8 +1143,8 @@ RED.projects.settings = (function() {
]
});
},
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
spinner.remove();
}
},
@@ -1277,8 +1278,8 @@ RED.projects.settings = (function() {
});
},
400: {
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
spinner.remove();
}
},
@@ -1404,8 +1405,8 @@ RED.projects.settings = (function() {
remoteNameInput.addClass('input-error');
done(error);
},
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
done(error);
}
},

View File

@@ -19,7 +19,45 @@ RED.projects = (function() {
var dialogBody;
var activeProject;
function reportUnexpectedError(error) {
var notification;
if (error.error === 'git_missing_user') {
notification = RED.notify("<p>You Git client is not configured with a username/email.</p>",{
fixed: true,
type:'error',
buttons: [
{
text: "Cancel",
click: function() {
notification.close();
}
},
{
text: "Configure Git client",
click: function() {
RED.userSettings.show('gitconfig');
notification.close();
}
}
]
})
} else {
console.log(error);
notification = RED.notify("<p>An unexpected error occurred:</p><p>"+error.message+"</p><small>code: "+error.error+"</small>",{
fixed: true,
modal: true,
type: 'error',
buttons: [
{
text: "Close",
click: function() {
notification.close();
}
}
]
})
}
}
var screens = {};
function initScreens() {
var migrateProjectHeader = $('<div class="projects-dialog-screen-start-hero"></div>');
@@ -565,8 +603,9 @@ RED.projects = (function() {
// getRepoAuthDetails(req);
console.log("git auth error",error);
},
'unexpected_error': function(error) {
console.log("unexpected_error",error)
'*': function(error) {
reportUnexpectedError(error);
$( dialog ).dialog( "close" );
}
}
}
@@ -1753,7 +1792,7 @@ RED.projects = (function() {
RED.notify(error.message,'error');
},
'unexpected_error': function(error) {
console.log(error);
reportUnexpectedError(error);
}
}
}
@@ -1800,7 +1839,8 @@ RED.projects = (function() {
var projectsAPI = {
sendRequest:sendRequest,
createBranchList:createBranchList,
addSpinnerOverlay:addSpinnerOverlay
addSpinnerOverlay:addSpinnerOverlay,
reportUnexpectedError:reportUnexpectedError
};
RED.projects.settings.init(projectsAPI);
RED.projects.userSettings.init(projectsAPI);

View File

@@ -487,8 +487,8 @@ RED.sidebar.versionControl = (function() {
refresh(true);
},
400: {
'unexpected_error': function(error) {
console.log(error);
'*': function(error) {
utils.reportUnexpectedError(error);
}
},
}