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, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 package org.apache.directory.server.core.interceptor; 021 022 023 import javax.naming.NamingException; 024 025 026 /** 027 * A {@link NamingException} that wraps uncaught runtime exceptions thrown 028 * from {@link Interceptor}s. 029 * 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 * @version $Rev: 896599 $, $Date: 2010-01-06 19:26:43 +0100 (Wed, 06 Jan 2010) $ 032 */ 033 public class InterceptorException extends NamingException 034 { 035 private static final long serialVersionUID = 3258690996517746233L; 036 037 /** 038 * The Interceptor causing the failure 039 */ 040 private final Interceptor interceptor; 041 042 043 /** 044 * Creates an InterceptorException without a message. 045 * 046 * @param interceptor the Interceptor causing the failure 047 */ 048 public InterceptorException(Interceptor interceptor) 049 { 050 this.interceptor = interceptor; 051 } 052 053 054 /** 055 * Creates an InterceptorException with a custom message. 056 * 057 * @param interceptor the Interceptor causing the failure 058 * @param explanation String explanation of why the Interceptor failed 059 */ 060 public InterceptorException(Interceptor interceptor, String explanation) 061 { 062 super( explanation ); 063 this.interceptor = interceptor; 064 } 065 066 067 /** 068 * Creates an InterceptorException without a message. 069 * 070 * @param interceptor the Interceptor causing the failure 071 * @param rootCause the root cause of this exception 072 */ 073 public InterceptorException(Interceptor interceptor, Throwable rootCause) 074 { 075 this( interceptor ); 076 super.setRootCause( rootCause ); 077 } 078 079 080 /** 081 * Creates an InterceptorException without a message. 082 * 083 * @param interceptor the Interceptor causing the failure 084 * @param explanation String explanation of why the Interceptor failed 085 * @param rootCause the root cause of this exception 086 */ 087 public InterceptorException(Interceptor interceptor, String explanation, Throwable rootCause) 088 { 089 this( interceptor, explanation ); 090 super.setRootCause( rootCause ); 091 } 092 093 094 /** 095 * Gets the interceptor this exception is associated with. 096 * 097 * @return the interceptor this exception is associated with 098 */ 099 public Interceptor getInterceptor() 100 { 101 return interceptor; 102 } 103 }