001package org.apache.maven.wagon; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022/** 023 * Root class for all exception in Wagon API 024 * 025 * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 026 * 027 */ 028public abstract class WagonException 029 extends Exception 030{ 031 /** 032 * the throwable that caused this exception to get thrown 033 */ 034 private Throwable cause; 035 036 037 /** 038 * Constructs a new WagonException with the specified detail message. 039 * The cause is not initialized, and may subsequently be initialized by a call to initCause 040 * 041 * @param message - the detail message (which is saved for later retrieval by the getMessage() method). 042 * @param cause - the cause (which is saved for later retrieval by the getCause() method). 043 * (A null value is permitted, and indicates that the cause is nonexistent or unknown.) 044 */ 045 public WagonException( final String message, final Throwable cause ) 046 { 047 super( message ); 048 initCause( cause ); 049 } 050 051 /** 052 * Constructs a new WagonException with the specified detail message and cause. 053 * 054 * @param message - the detail message (which is saved for later retrieval by the getMessage() method). 055 */ 056 public WagonException( final String message ) 057 { 058 super( message ); 059 } 060 061 /** 062 * Returns the cause of this throwable or null if the cause is nonexistent or unknown. 063 * (The cause is the throwable that caused this exception to get thrown.) 064 * 065 * @return the cause of this exception or null if the cause is nonexistent or unknown. 066 */ 067 public Throwable getCause() 068 { 069// try 070// { 071// Class clazz = getClass().getSuperclass(); 072// 073// Method method = clazz.getMethod( "gatCause" , null ); 074// 075// Throwable retValue = (Throwable) method.invoke( this, null ); 076// return retValue; 077// } 078// catch( Exception e) 079// { 080// 081// } 082 083 return cause; 084 } 085 086 087 /** 088 * Initializes the cause of this throwable to the specified value. 089 * (The cause is the throwable that caused this throwable to get thrown.) 090 * This method can be called at most once. 091 * It is generally called from within the constructor, or immediately after creating the throwable. 092 * If this throwable was created with WagonException(Throwable) or WagonException(String,Throwable), 093 * this method cannot be called even once. 094 * 095 * @return a reference to this Throwable instance. 096 */ 097 public Throwable initCause( final Throwable cause ) 098 { 099// try 100// { 101// Class clazz = getClass().getSuperclass(); 102// Class[] parameterTypes = new Class[1]; 103// parameterTypes[0] = Throwable.class; 104// Method method = clazz.getMethod( "initCause" , parameterTypes); 105// Object[] params = { cause }; 106// method.invoke( this, params ); 107// } 108// catch( Exception e) 109// { 110// 111// } 112 this.cause = cause; 113 return this; 114 } 115 116}