1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 package org.apache.zookeeper.cli;
20 
21 @SuppressWarnings("serial")
22 public class CliException extends Exception {
23 
24     protected int exitCode;
25 
26     protected static final int DEFAULT_EXCEPTION_EXIT_CODE = 1;
27 
CliException(String message)28     public CliException(String message) {
29         this(message, DEFAULT_EXCEPTION_EXIT_CODE);
30     }
31 
CliException(String message, int exitCode)32     public CliException(String message, int exitCode) {
33         super(message);
34         this.exitCode = exitCode;
35     }
36 
CliException(Throwable cause)37     public CliException(Throwable cause) {
38         this(cause, DEFAULT_EXCEPTION_EXIT_CODE);
39     }
40 
CliException(Throwable cause, int exitCode)41     public CliException(Throwable cause, int exitCode) {
42         super(cause);
43         this.exitCode = exitCode;
44     }
45 
CliException(String message, Throwable cause)46     public CliException(String message, Throwable cause) {
47         this(message, cause, DEFAULT_EXCEPTION_EXIT_CODE);
48     }
49 
CliException(String message, Throwable cause, int exitCode)50     public CliException(String message, Throwable cause, int exitCode) {
51         super(message, cause);
52         this.exitCode = exitCode;
53     }
54 
getExitCode()55     public int getExitCode() {
56         return exitCode;
57     }
58 
59 }
60