001 /*
002 * jDTAUS - DTAUS fileformat.
003 * Copyright (c) 2005 Christian Schulte <cs@schulte.it>
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either
008 * version 2.1 of the License, or any later version.
009 *
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013 * Lesser General Public License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public
016 * License along with this library; if not, write to the Free Software
017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
018 *
019 */
020 package org.jdtaus.core.container;
021
022 import java.util.Locale;
023
024 /**
025 * Gets thrown when an implementation fails to operate.
026 *
027 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
028 * @version $Id: ImplementationException.java 1914 2007-03-01 02:20:44Z schulte2005 $
029 */
030 public class ImplementationException extends IllegalStateException
031 {
032
033 //--Constructors------------------------------------------------------------
034
035 /**
036 * Creates a new instance of {@code ImplementationException} taking a
037 * causing {@code Throwable}.
038 *
039 * @param implementation the failing implementation.
040 * @param cause the causing throwable.
041 */
042 public ImplementationException(final Implementation implementation,
043 final Throwable cause)
044 {
045
046 super(ImplementationExceptionBundle.getImplementationExceptionMessage(
047 Locale.getDefault()).format(new Object[] {
048 cause != null ? cause.getMessage() : null }));
049
050 this.initCause(cause);
051 this.implementation = implementation;
052 }
053
054 /**
055 * Creates a new instance of {@code ImplementationException} taking a
056 * message.
057 *
058 * @param implementation the failing implementation.
059 * @param msg the message describing the error.
060 */
061 public ImplementationException(final Implementation implementation,
062 final String msg)
063 {
064
065 super(ImplementationExceptionBundle.getImplementationExceptionMessage(
066 Locale.getDefault()).format(new Object[] { msg }));
067
068 this.implementation = implementation;
069 }
070
071 //------------------------------------------------------------Constructors--
072 //--ImplementationException-------------------------------------------------
073
074 /**
075 * The failing implementation.
076 * @serial
077 */
078 private Implementation implementation;
079
080 /**
081 * Gets the failing implementation.
082 *
083 * @return the failing implementation or {@code null}.
084 */
085 public Implementation getImplementation()
086 {
087 return this.implementation;
088 }
089
090 //-------------------------------------------------ImplementationException--
091
092 }