Error handling for plugin installation/uninstallaion

This commit is contained in:
Rene Pfeuffer
2019-10-01 09:33:48 +02:00
parent 9261513555
commit aded308138
8 changed files with 40 additions and 7 deletions

View File

@@ -97,7 +97,16 @@ class MultiPluginActionModal extends React.Component<Props, State> {
loading: true
});
apiClient.post(pendingPlugins._links.cancel.href).then(() => this.reload());
apiClient
.post(pendingPlugins._links.cancel.href)
.then(() => this.reload())
.catch(error => {
this.setState({
success: false,
loading: false,
error: error
});
});
};
updateAll = () => {
@@ -239,6 +248,7 @@ class MultiPluginActionModal extends React.Component<Props, State> {
renderBody = () => {
const { actionType } = this.props;
const { error } = this.state;
return (
<>
<div className="media">
@@ -247,6 +257,11 @@ class MultiPluginActionModal extends React.Component<Props, State> {
{this.renderModalContent()}
</div>
</div>
{!!error && (
<div className="media">
<ErrorNotification error={error} />
</div>
)}
{actionType === MultiPluginActionType.EXECUTE_PENDING && (
<div className="media">{this.renderNotifications()}</div>
)}

View File

@@ -121,6 +121,7 @@ class PluginModal extends React.Component<Props, State> {
.catch(error => {
this.setState({
loading: false,
success: false,
error: error
});
});

View File

@@ -288,7 +288,7 @@ public class DefaultPluginManager implements PluginManager {
pendingInstallQueue.forEach(PendingPluginInstallation::cancel);
pendingUninstallQueue.clear();
pendingInstallQueue.clear();
getInstalled().forEach(p -> p.setUninstallable(isUninstallable(p)));
updateMayUninstallFlag();
}
@Override

View File

@@ -30,7 +30,7 @@ class PendingPluginInstallation {
Files.delete(file);
plugin.cancelInstallation();
} catch (IOException ex) {
throw new PluginFailedToCancelInstallationException("failed to cancel installation of plugin " + name, ex);
throw new PluginFailedToCancelInstallationException("failed to cancel plugin installation ", name, ex);
}
}
}

View File

@@ -26,7 +26,7 @@ class PendingPluginUninstallation {
Files.delete(uninstallFile);
plugin.setMarkedForUninstall(false);
} catch (IOException ex) {
throw new PluginFailedToCancelInstallationException("failed to cancel uninstallation of plugin " + name, ex);
throw new PluginFailedToCancelInstallationException("failed to cancel uninstallation", name, ex);
}
}
}

View File

@@ -1,7 +1,16 @@
package sonia.scm.plugin;
public class PluginFailedToCancelInstallationException extends RuntimeException {
public PluginFailedToCancelInstallationException(String message, Throwable cause) {
super(message, cause);
import sonia.scm.ExceptionWithContext;
import static sonia.scm.ContextEntry.ContextBuilder.entity;
public class PluginFailedToCancelInstallationException extends ExceptionWithContext {
public PluginFailedToCancelInstallationException(String message, String name, Exception cause) {
super(entity("plugin", name).build(), message, cause);
}
@Override
public String getCode() {
return "65RdZ5atX1";
}
}

View File

@@ -175,6 +175,10 @@
"40RaYIeeR1": {
"displayName": "Es wurden keine Änderungen durchgeführt",
"description": "Das Repository wurde nicht verändert. Daher konnte kein neuer Commit erzeugt werden."
},
"65RdZ5atX1": {
"displayName": "Fehler beim Löschen von Plugin-Dateien",
"description": "Einige Dateien für die Plugin-Deinstallation konnten nicht gelöscht werden. Dieses kann zu Inkonsistenzen führen, so dass der SCM-Manager nicht mehr korrekt starten kann. Bitte prüfen Sie die Logs und bereinigen Sie das Plugin-Verzeichnis des SCM-Managers manuell."
}
},
"namespaceStrategies": {

View File

@@ -175,6 +175,10 @@
"40RaYIeeR1": {
"displayName": "No changes were made",
"description": "No changes were made to the files of the repository. Therefor no new commit could be created."
},
"65RdZ5atX1": {
"displayName": "Error removing plugin files",
"description": "Some files to cancel the plugin (un)installation could not be deleted. This can lead to inconsistencies so that the SCM-Manager cannot restart properly. Please check the logs and clean up the plugin folder manually."
}
},
"namespaceStrategies": {