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();