Simplify an exception's constructor.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=125127036
This commit is contained in:
cgoldfeder 2016-06-16 19:04:21 -07:00 committed by Ben McIlwain
parent 31ddced437
commit 1d2d81492e
2 changed files with 6 additions and 7 deletions

View file

@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableSet;
import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ExternalMessagingName;
import google.registry.model.eppinput.EppInput.InnerCommand; import google.registry.model.eppinput.EppInput.InnerCommand;
import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppinput.EppInput.ResourceCommandWrapper;
import google.registry.model.eppoutput.Result; import google.registry.model.eppoutput.Result;
import google.registry.model.eppoutput.Result.Code; import google.registry.model.eppoutput.Result.Code;
@ -211,11 +211,13 @@ public abstract class EppException extends Exception {
/** Specified command is not implemented. */ /** Specified command is not implemented. */
@EppResultCode(Code.UnimplementedCommand) @EppResultCode(Code.UnimplementedCommand)
public static class UnimplementedCommandException extends EppException { public static class UnimplementedCommandException extends EppException {
public UnimplementedCommandException(InnerCommand command, ResourceCommand resourceCommand) { public UnimplementedCommandException(InnerCommand command) {
super(String.format( super(String.format(
"No flow found for %s with extension %s", "No flow found for %s with extension %s",
command.getClass().getSimpleName(), command.getClass().getSimpleName(),
resourceCommand == null ? null : resourceCommand.getClass().getSimpleName())); command instanceof ResourceCommandWrapper
? ((ResourceCommandWrapper) command).getResourceCommand().getClass().getSimpleName()
: null));
} }
} }

View file

@ -326,10 +326,7 @@ public class FlowPicker {
} }
} }
// Nothing usable was found, so throw an exception. // Nothing usable was found, so throw an exception.
throw new UnimplementedCommandException( throw new UnimplementedCommandException(innerCommand);
innerCommand,
innerCommand instanceof ResourceCommandWrapper
? ((ResourceCommandWrapper) innerCommand).getResourceCommand() : null);
} }
/** Command missing. */ /** Command missing. */