improve error handling on repository import if the credentials were wrong or missing

This commit is contained in:
Eduard Heimbuch
2020-11-26 12:57:40 +01:00
parent 0682118879
commit a7c4d41e4e
7 changed files with 111 additions and 43 deletions

View File

@@ -46,6 +46,7 @@ import sonia.scm.repository.RepositoryManager;
import sonia.scm.repository.RepositoryPermissions;
import sonia.scm.repository.RepositoryType;
import sonia.scm.repository.api.Command;
import sonia.scm.repository.api.ImportFailedException;
import sonia.scm.repository.api.PullCommandBuilder;
import sonia.scm.repository.api.RepositoryService;
import sonia.scm.repository.api.RepositoryServiceFactory;
@@ -216,9 +217,12 @@ public class RepositoryImportResource {
}
pullCommand.pull(request.getUrl());
} catch (ImportFailedException ex) {
handleImportFailure(ex, repository);
throw ex;
} catch (Exception ex) {
handleImportFailure(ex, repository);
throw new InternalRepositoryException(repository, "Import failed. Most likely the credentials are wrong or missing.", ex);
throw new InternalRepositoryException(repository, "Repository Import failed.", ex);
}
return Response.created(URI.create(resourceLinks.repository().self(repository.getNamespace(), repository.getName()))).build();

View File

@@ -286,12 +286,16 @@
"FVS9JY1T21": {
"displayName": "Fehler bei der Anfrage",
"description": "Bei der Anfrage trat ein Fehler auf. Prüfen Sie bitte den Status der HTTP Antwort und die konkrete Meldung."
},
"D6SHRfqQw1": {
"displayName": "Repository Import fehlgeschlagen",
"description": "Das Repository konnte nicht importiert werden. Entweder wurden die Zugangsdaten (Benutzername/Passwort) nicht gesetzt oder sind fehlerhaft. Bitte prüfen Sie Ihre Eingaben."
}
},
"namespaceStrategies": {
"UsernameNamespaceStrategy": "Benutzername",
"CustomNamespaceStrategy": "Benutzerdefiniert",
"CurrentYearNamespaceStrategy": "Aktuelles Jahr",
"UsernameNamespaceStrategy": "Benutzername",
"CustomNamespaceStrategy": "Benutzerdefiniert",
"CurrentYearNamespaceStrategy": "Aktuelles Jahr",
"RepositoryTypeNamespaceStrategy": "Repository Typ"
}
}

View File

@@ -286,6 +286,10 @@
"FVS9JY1T21": {
"displayName": "Error in the request",
"description": "While processing the request there was an error. Please check the http return status and the concrete error message."
},
"D6SHRfqQw1": {
"displayName": "Repository import failed",
"description": "The repository could not be imported. Either the credentials (username/password) are wrong or missing. Please check your inputs."
}
},
"namespaceStrategies": {