| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| nl.toolforge.karma.core.cmd.CommandLoadException |
|
|
| 1 | /* |
|
| 2 | Karma core - Core of the Karma application |
|
| 3 | Copyright (C) 2004 Toolforge <www.toolforge.nl> |
|
| 4 | ||
| 5 | This library is free software; you can redistribute it and/or |
|
| 6 | modify it under the terms of the GNU Lesser General Public |
|
| 7 | License as published by the Free Software Foundation; either |
|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|
| 9 | ||
| 10 | This library is distributed in the hope that it will be useful, |
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 | Lesser General Public License for more details. |
|
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public |
|
| 16 | License along with this library; if not, write to the Free Software |
|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 18 | */ |
|
| 19 | package nl.toolforge.karma.core.cmd; |
|
| 20 | ||
| 21 | import nl.toolforge.karma.core.ErrorCode; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * Thrown when command loading failed. |
|
| 25 | * |
|
| 26 | * @author D.A. Smedes |
|
| 27 | * @version $Id: CommandLoadException.java,v 1.8 2004/11/02 23:57:05 asmedes Exp $ |
|
| 28 | */ |
|
| 29 | public class CommandLoadException extends Exception { |
|
| 30 | ||
| 31 | 0 | private ErrorCode errorCode = null; |
| 32 | 0 | private Object[] messageArguments = null; |
| 33 | ||
| 34 | public static final String EXCEPTION_PREFIX = "CML-"; |
|
| 35 | ||
| 36 | 0 | public static final ErrorCode LOAD_FAILURE_FOR_DEFAULT_COMMANDS = new ErrorCode(EXCEPTION_PREFIX + "00001"); |
| 37 | ||
| 38 | 0 | public static final ErrorCode LOAD_FAILURE_FOR_PLUGIN_COMMANDS_FILE = new ErrorCode(EXCEPTION_PREFIX + "00002"); |
| 39 | ||
| 40 | 0 | public static final ErrorCode DUPLICATE_COMMAND = new ErrorCode(EXCEPTION_PREFIX + "00003"); |
| 41 | ||
| 42 | public CommandLoadException(ErrorCode errorCode) { |
|
| 43 | 0 | this(errorCode, null); |
| 44 | 0 | } |
| 45 | ||
| 46 | public CommandLoadException(ErrorCode errorCode, Object[] messageArguments) { |
|
| 47 | 0 | super(); |
| 48 | 0 | this.errorCode = errorCode; |
| 49 | 0 | this.messageArguments = messageArguments; |
| 50 | 0 | } |
| 51 | ||
| 52 | public CommandLoadException(Throwable t, ErrorCode errorCode, Object[] messageArguments) { |
|
| 53 | 0 | super(t); |
| 54 | 0 | this.errorCode = errorCode; |
| 55 | 0 | this.messageArguments = messageArguments; |
| 56 | 0 | } |
| 57 | ||
| 58 | public String getMessage() { |
|
| 59 | 0 | if (messageArguments != null && messageArguments.length > 0) { |
| 60 | 0 | errorCode.setMessageArguments(messageArguments); |
| 61 | } |
|
| 62 | 0 | return errorCode.getErrorMessage(); |
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}. |
|
| 67 | * @return |
|
| 68 | */ |
|
| 69 | public final ErrorCode getErrorCode() { |
|
| 70 | 0 | return errorCode; |
| 71 | } |
|
| 72 | ||
| 73 | public final Object[] getMessageArguments() { |
|
| 74 | 0 | return messageArguments; |
| 75 | } |
|
| 76 | ||
| 77 | ||
| 78 | ||
| 79 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |