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 */ 018 019package org.apache.oozie.client; 020 021/** 022 * Exception thrown by the {@link OozieClient}. 023 */ 024public class OozieClientException extends Exception { 025 public static final String UNSUPPORTED_VERSION = "UNSUPPORTED_VERSION"; 026 public static final String IO_ERROR = "IO_ERROR"; 027 public static final String INVALID_FILTER = "INVALID_FILTER"; 028 public static final String INVALID_INPUT = "INVALID_INPUT"; 029 public static final String OTHER = "OTHER"; 030 public static final String AUTHENTICATION = "AUTHENTICATION"; 031 032 private String errorCode; 033 034 /** 035 * Create an exception. 036 * 037 * @param errorCode error code. 038 * @param message error message. 039 */ 040 public OozieClientException(String errorCode, String message) { 041 super(message); 042 this.errorCode = errorCode; 043 } 044 045 /** 046 * Create an exception with a cause. 047 * 048 * @param errorCode error code. 049 * @param cause exception cause. 050 */ 051 public OozieClientException(String errorCode, Throwable cause) { 052 super(cause); 053 this.errorCode = errorCode; 054 } 055 056 /** 057 * Create an exception with a cause. 058 * 059 * @param errorCode error code. 060 * @param message error message. 061 * @param cause exception cause. 062 */ 063 public OozieClientException(String errorCode, String message, Throwable cause) { 064 super(message, cause); 065 this.errorCode = errorCode; 066 } 067 068 /** 069 * Return the exception error code. 070 * 071 * @return the exception error code. 072 */ 073 public String getErrorCode() { 074 return errorCode; 075 } 076 077 /** 078 * Return the string representatio of the exception. 079 * 080 * @return the string representatio of the exception. 081 */ 082 public String toString() { 083 return errorCode + " : " + super.getMessage(); 084 } 085 086}