From d618ae758bd43542e4b02cd8ea1475ca7a8d47c7 Mon Sep 17 00:00:00 2001 From: guyben Date: Thu, 26 Apr 2018 07:20:08 -0700 Subject: [PATCH] Throw exception when server returns error in ListObjectsCommand ListObjectsCommand is a base class for a number of List commands that query the tools server with the command input, and then show the user the server's reply. For example, ListDomainsCommand queries ListDomainsAction with the input TLDs from the user, and then prints the resulting domains for the user. Currently, when the server query returns an error (because, e.g., the user of ListDomainsCommand gave a non-existing TLD) - ListObjectsCommand just prints the error message to stdout, and returns successfully. That means that any automatic tool would think the command succeeded. This CL changes the behavior of ListObjectsCommand to throw an exception with the error message if the server returned an error. This results in the nomulus command failing if the server encountered an error. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=194393053 --- java/google/registry/tools/ListObjectsCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/google/registry/tools/ListObjectsCommand.java b/java/google/registry/tools/ListObjectsCommand.java index c481375e4..1199ee7c1 100644 --- a/java/google/registry/tools/ListObjectsCommand.java +++ b/java/google/registry/tools/ListObjectsCommand.java @@ -114,9 +114,9 @@ abstract class ListObjectsCommand implements RemoteApiCommand, ServerSideCommand if (status.equals("error")) { obj = responseMap.get("error"); if (obj == null) { - throw new VerifyException("Server returned no error message"); + throw new VerifyException("Server returned an error with no error message"); } - System.out.println(obj); + throw new VerifyException(String.format("Server returned an error with message '%s'", obj)); // Handle success. } else if (status.equals("success")) { obj = responseMap.get("lines");