mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Correctly set HTTP error status codes when list objects fails
This makes the associated nomulus tool commands correctly return error exit codes when the server-side component fails. This improves scriptability. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140543216
This commit is contained in:
parent
b35ac10b7e
commit
5f32d1bbeb
8 changed files with 31 additions and 11 deletions
|
@ -15,6 +15,8 @@
|
|||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
|
@ -120,6 +122,8 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
|
|||
if (message == null) {
|
||||
message = e.getClass().getName();
|
||||
}
|
||||
response.setStatus(
|
||||
e instanceof IllegalArgumentException ? SC_BAD_REQUEST : SC_INTERNAL_SERVER_ERROR);
|
||||
response.setPayload(ImmutableMap.of(
|
||||
"error", message,
|
||||
"status", "error"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue