Graceful message and exit for wrong value of phase#84
Conversation
sonalgoyal
left a comment
There was a problem hiding this comment.
Cant we just throw an exception and exit with the right message?
| private ClientOptions options; | ||
|
|
||
| public static final Log LOG = LogFactory.getLog(Client.class); | ||
| public static final int EXIT_STATUS_ILLEGAL_CMD = 127; |
| System.exit(0); | ||
| } | ||
| String phase = options.get(ClientOptions.PHASE).value.trim(); | ||
| if (ZinggOptions.getByValue(phase) == null) { |
There was a problem hiding this comment.
throw exception with right message
There was a problem hiding this comment.
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.
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.
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