Throw bad request in case of non existing parent project When the parent project provided with the request does not exist on the target server a bad request is returned to the client. Change-Id: Ie3949b6d84f38143359a4daf54e778a8ec84da44
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java index 59c43fe..2a9d057 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java +++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
@@ -191,6 +191,8 @@ } importLog.onImport((IdentifiedUser) currentUser.get(), project, input.from); + } catch (BadRequestException e) { + throw e; } catch (Exception e) { importLog.onImport((IdentifiedUser) currentUser.get(), project, input.from, e); @@ -218,12 +220,12 @@ updateAndEnd(pm); } - private void checkPreconditions(ProgressMonitor pm) throws ValidationException { + private void checkPreconditions(ProgressMonitor pm) throws BadRequestException { pm.beginTask("Check preconditions", 1); ProjectState p = projectCache.get(parent); if (p == null) { - throw new ValidationException(format( - "Parent project %s does not exist in target,", parent.get())); + throw new BadRequestException(format( + "Parent project '%s' does not exist in target.", parent.get())); } updateAndEnd(pm); }