001    /**
002     * Copyright (c) 2010 Yahoo! Inc. All rights reserved.
003     * Licensed under the Apache License, Version 2.0 (the "License");
004     * you may not use this file except in compliance with the License.
005     * You may obtain a copy of the License at
006     *
007     *   http://www.apache.org/licenses/LICENSE-2.0
008     *
009     *  Unless required by applicable law or agreed to in writing, software
010     *  distributed under the License is distributed on an "AS IS" BASIS,
011     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012     *  See the License for the specific language governing permissions and
013     *  limitations under the License. See accompanying LICENSE file.
014     */
015    package org.apache.oozie.client;
016    
017    /**
018     * Exception thrown by the {@link OozieClient}.
019     */
020    public class OozieClientException extends Exception {
021        public static final String UNSUPPORTED_VERSION = "UNSUPPORTED_VERSION";
022        public static final String IO_ERROR = "IO_ERROR";
023        public static final String INVALID_FILTER = "INVALID_FILTER";
024        public static final String INVALID_INPUT = "INVALID_INPUT";
025        public static final String OTHER = "OTHER";
026        public static final String AUTHENTICATION = "AUTHENTICATION";
027    
028        private String errorCode;
029    
030        /**
031         * Create an exception.
032         *
033         * @param errorCode error code.
034         * @param message error message.
035         */
036        public OozieClientException(String errorCode, String message) {
037            super(message);
038            this.errorCode = errorCode;
039        }
040    
041        /**
042         * Create an exception with a cause.
043         *
044         * @param errorCode error code.
045         * @param cause exception cause.
046         */
047        public OozieClientException(String errorCode, Throwable cause) {
048            super(cause);
049            this.errorCode = errorCode;
050        }
051    
052        /**
053         * Create an exception with a cause.
054         *
055         * @param errorCode error code.
056         * @param message error message.
057         * @param cause exception cause.
058         */
059        public OozieClientException(String errorCode, String message, Throwable cause) {
060            super(message, cause);
061            this.errorCode = errorCode;
062        }
063    
064        /**
065         * Return the exception error code.
066         *
067         * @return the exception error code.
068         */
069        public String getErrorCode() {
070            return errorCode;
071        }
072    
073        /**
074         * Return the string representatio of the exception.
075         *
076         * @return the string representatio of the exception.
077         */
078        public String toString() {
079            return errorCode + " : " + super.getMessage();
080        }
081    
082    }