View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package goldengate.common.command.exception;
22  
23  import goldengate.common.command.ReplyCode;
24  
25  /**
26   * Abstract class for exception in commands
27   *
28   * @author Frederic Bregier
29   *
30   */
31  @SuppressWarnings("serial")
32  public abstract class CommandAbstractException extends Exception {
33      /**
34       * Associated code
35       */
36      public ReplyCode code = null;
37  
38      /**
39       * Associated Message if any
40       */
41      public String message = null;
42  
43      /**
44       * Unique constructor
45       *
46       * @param code
47       * @param message
48       */
49      public CommandAbstractException(ReplyCode code, String message) {
50          super(code.getMesg());
51          this.code = code;
52          this.message = message;
53      }
54  
55      /**
56  	 *
57  	 */
58      @Override
59      public String toString() {
60          return "Code: " + code.name() + " Mesg: " +
61                  (message != null? message : "no specific message");
62      }
63  
64      /*
65       * (non-Javadoc)
66       *
67       * @see java.lang.Throwable#getMessage()
68       */
69      @Override
70      public String getMessage() {
71          return toString();
72      }
73  }