提交 41354d8c 编写于 作者: K kohsuke

allow exceptions to be thrown for convenience

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@17846 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e09b2e61
......@@ -26,6 +26,7 @@ package hudson.cli;
import hudson.ExtensionPoint;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.AbortException;
import hudson.remoting.Channel;
import hudson.remoting.Callable;
import hudson.model.Hudson;
......@@ -142,6 +143,10 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
stderr.println(e.getMessage());
printUsage(stderr, p);
return -1;
} catch (AbortException e) {
// signals an error without stack trace
stderr.println(e.getMessage());
return -1;
} catch (Exception e) {
e.printStackTrace(stderr);
return -1;
......@@ -153,6 +158,12 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
*
* @return
* 0 to indicate a success, otherwise an error code.
* @throws AbortException
* If the processing should be aborted. Hudson will report the error message
* without stack trace, and then exits this command.
* @throws Exception
* All the other exceptions cause the stack trace to be dumped, and then
* the command exits with an error code.
*/
protected abstract int run() throws Exception;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册