Merge changes from topic "RestApiException-refactoring"
* changes: Make RestApiException(String, Exception) constructor protected Do not throw generic RestApiException to signal an internal server error ProjectsImpl: Use asRestApiException method to wrap exception as RestApiException Make RestApiException(String) constructor protected Submit: Do not throw generic RestApiException to signal an internal server error RestApiException: Make default constructor protected Remove unused default constructors from RestApiException classes PluginCollection: Pass id which was not found to ResourceNotFoundException RestApiServlet: Return error message when raw input is not supported Make error response for non-default dashboards consistent & include message
This commit is contained in:
@@ -212,12 +212,10 @@ public class Submit
|
||||
return Response.ok(new Output(change));
|
||||
}
|
||||
|
||||
String msg =
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"change %s of project %s unexpectedly had status %s after submit attempt",
|
||||
updatedChange.getId(), updatedChange.getProject(), updatedChange.getStatus());
|
||||
logger.atWarning().log(msg);
|
||||
throw new RestApiException(msg);
|
||||
updatedChange.getId(), updatedChange.getProject(), updatedChange.getStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ package com.google.gerrit.server.restapi.project;
|
||||
import com.google.gerrit.extensions.api.projects.DashboardInfo;
|
||||
import com.google.gerrit.extensions.api.projects.SetDashboardInput;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.RestCollectionCreateView;
|
||||
@@ -48,7 +48,7 @@ public class CreateDashboard
|
||||
throws RestApiException, IOException, PermissionBackendException {
|
||||
parent.getProjectState().checkStatePermitsWrite();
|
||||
if (!DashboardsCollection.isDefaultDashboard(id)) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new MethodNotAllowedException("cannot create non-default dashboard");
|
||||
}
|
||||
SetDefaultDashboard set = setDefault.get();
|
||||
set.inherited = inherited;
|
||||
|
@@ -43,6 +43,6 @@ public class DeleteDashboard implements RestModifyView<DashboardResource, SetDas
|
||||
}
|
||||
|
||||
// TODO: Implement delete of dashboards by API.
|
||||
throw new MethodNotAllowedException();
|
||||
throw new MethodNotAllowedException("cannot delete non-default dashboard");
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public class SetDashboard implements RestModifyView<DashboardResource, SetDashbo
|
||||
return defaultSetter.get().apply(resource, input);
|
||||
}
|
||||
|
||||
// TODO: Implement creation/update of dashboards by API.
|
||||
throw new MethodNotAllowedException();
|
||||
// TODO: Implement update of dashboards by API.
|
||||
throw new MethodNotAllowedException("cannot update non-default dashboard");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user