-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graceful message and exit for wrong value of phase #84
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cant we just throw an exception and exit with the right message?
@@ -21,6 +22,7 @@ | |||
private ClientOptions options; | |||
|
|||
public static final Log LOG = LogFactory.getLog(Client.class); | |||
public static final int EXIT_STATUS_ILLEGAL_CMD = 127; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -131,6 +133,11 @@ public static void main(String... args) { | |||
System.exit(0); | |||
} | |||
String phase = options.get(ClientOptions.PHASE).value.trim(); | |||
if (ZinggOptions.getByValue(phase) == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw exception with right message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the message as part of thrown exception
Apologies for this message. Zingg has encountered an error. 'findTrainingDat' is not a valid phase. Valid phases are: train|match|trainMatch|findTrainingData|label|link
int exitStatusExpected = 127; // error code for an illegal command e.g. typo | ||
try { | ||
String zinggInvalidPhaseCmd = "scripts/zingg.sh --phase findTrainingDat --conf examples/febrl/config.json"; | ||
Process p = Runtime.getRuntime().exec(zinggInvalidPhaseCmd, null, new File(System.getenv("ZINGG_HOME"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just call the client with the args instead of execing a new process here? and simply assert that an exception happens ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testcases have been updated to test the new functionality that is refactored into ZinggOptions.verifyPhase(phase).
ZinggOptions has been chosen for it is the central place to maintain zingg options or phases.
#81 wrong value of phase shows stack trace - should be handled gracefully