001 /** 002 * 003 * Copyright 2003-2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.geronimo.common; 019 020 021 /** 022 * @version $Rev: 356022 $ $Date: 2005-12-11 12:58:34 -0800 (Sun, 11 Dec 2005) $ 023 */ 024 public class DeploymentException extends Exception { 025 026 public DeploymentException() { 027 } 028 029 public DeploymentException(Throwable cause) { 030 super(cause); 031 } 032 033 public DeploymentException(String message) { 034 super(message); 035 } 036 037 public DeploymentException(String message, Throwable cause) { 038 super(message, cause); 039 } 040 041 public DeploymentException cleanse() { 042 if(null != getCause()) { 043 Throwable root = this; 044 CleanseException previousEx = null; 045 CleanseException rootEx = null; 046 while (null != root) { 047 Throwable e = root.getCause(); 048 CleanseException exception = new CleanseException(root.getMessage(), root.toString()); 049 if (null == rootEx) { 050 rootEx = exception; 051 } 052 exception.setStackTrace(root.getStackTrace()); 053 if (null != previousEx) { 054 previousEx.initCause(exception); 055 } 056 previousEx = exception; 057 root = e; 058 } 059 return rootEx; 060 } 061 062 return this; 063 } 064 065 private static class CleanseException extends DeploymentException { 066 private final String toString; 067 068 public CleanseException(String message, String toString) { 069 super(message); 070 this.toString = toString; 071 } 072 073 public String toString() { 074 return toString; 075 } 076 } 077 }