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