diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/ComponentException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/ComponentException.java new file mode 100644 index 000000000..0f38a7b64 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/ComponentException.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.myrmidon.interfaces; + +/** + * An exception thrown by a Myrmidon component. This is a convenience + * class, which can be sub-classes to create exceptions for specific components. + * + * @author Peter Donald + * @version $Revision$ $Date$ + */ +public class ComponentException + extends Exception +{ + /** + * The Throwable that caused this exception to be thrown. + */ + private final Throwable m_throwable; + + /** + * Constructs a non-cascaded exception. + * + * @param message The detail message for this exception. + */ + public ComponentException( final String message ) + { + this( message, null ); + } + + /** + * Constructs a cascaded exception. + * + * @param message The detail message for this exception. + * @param throwable the root cause of the exception + */ + public ComponentException( final String message, final Throwable throwable ) + { + super( message ); + m_throwable = throwable; + } + + /** + * Retrieve root cause of the exception. + * + * @return the root cause + */ + public final Throwable getCause() + { + return m_throwable; + } +} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/builder/ProjectException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/builder/ProjectException.java index 86b9dc5d9..01b2771ca 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/builder/ProjectException.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/builder/ProjectException.java @@ -7,6 +7,8 @@ */ package org.apache.myrmidon.interfaces.builder; +import org.apache.myrmidon.interfaces.ComponentException; + /** * A cascading exception thrown on a problem constructing a Project model. * @@ -14,43 +16,26 @@ package org.apache.myrmidon.interfaces.builder; * @version $Revision$ $Date$ */ public class ProjectException - extends Exception + extends ComponentException { /** - * If this exception is cascaded, the cause of this exception. - */ - private final Throwable m_throwable; - - /** - * Constructs an non-cascaded exception with a message + * Constructs a non-cascaded exception. * - * @param message the message + * @param message The detail message for this exception. */ public ProjectException( final String message ) - { - this( message, null ); - } - - /** - * Constructs a cascaded exception with the supplied message, which links the - * Throwable provided. - * - * @param message the message - * @param throwable the throwable that caused this exception - */ - public ProjectException( final String message, final Throwable throwable ) { super( message ); - m_throwable = throwable; } /** - * Retrieve root cause of the exception. + * Constructs a cascaded exception. * - * @return the root cause + * @param message The detail message for this exception. + * @param throwable the root cause of the exception */ - public final Throwable getCause() + public ProjectException( final String message, final Throwable throwable ) { - return m_throwable; + super( message, throwable ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/deployer/DeploymentException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/deployer/DeploymentException.java index 98fc7cbed..82347fedf 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/deployer/DeploymentException.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/deployer/DeploymentException.java @@ -7,49 +7,35 @@ */ package org.apache.myrmidon.interfaces.deployer; +import org.apache.myrmidon.interfaces.ComponentException; + /** * Exception to indicate error deploying. * * @author Peter Donald * @version $Revision$ $Date$ */ -public final class DeploymentException - extends Exception +public class DeploymentException + extends ComponentException { /** - * The Throwable that caused this exception to be thrown. - */ - private final Throwable m_throwable; - - /** - * Construct a new DeploymentException instance. + * Constructs a non-cascaded exception. * * @param message The detail message for this exception. */ public DeploymentException( final String message ) { - this( message, null ); + super( message ); } /** - * Construct a new DeploymentException instance. + * Constructs a cascaded exception. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public DeploymentException( final String message, final Throwable throwable ) { - super( message ); - m_throwable = throwable; - } - - /** - * Retrieve root cause of the exception. - * - * @return the root cause - */ - public final Throwable getCause() - { - return m_throwable; + super( message, throwable ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleException.java index 1cdf75f24..67af367f3 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleException.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleException.java @@ -7,6 +7,8 @@ */ package org.apache.myrmidon.interfaces.role; +import org.apache.myrmidon.interfaces.ComponentException; + /** * An exception thrown by the RoleManager. * @@ -14,32 +16,26 @@ package org.apache.myrmidon.interfaces.role; * @version $Revision$ $Date$ */ public class RoleException - extends Exception + extends ComponentException { /** - * The Throwable that caused this exception to be thrown. + * Constructs a non-cascaded exception. + * + * @param message The detail message for this exception. */ - private final Throwable m_throwable; - public RoleException( final String message ) - { - this( message, null ); - } - - public RoleException( final String message, - final Throwable throwable ) { super( message ); - m_throwable = throwable; } /** - * Retrieve root cause of the exception. + * Constructs a cascaded exception. * - * @return the root cause + * @param message The detail message for this exception. + * @param throwable the root cause of the exception */ - public final Throwable getCause() + public RoleException( final String message, final Throwable throwable ) { - return m_throwable; + super( message, throwable ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/service/AntServiceException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/service/AntServiceException.java index cf77eba13..f5dd77539 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/service/AntServiceException.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/service/AntServiceException.java @@ -7,6 +7,8 @@ */ package org.apache.myrmidon.interfaces.service; +import org.apache.myrmidon.interfaces.ComponentException; + /** * ServiceException thrown when a service can not be created for * some reason. @@ -15,51 +17,27 @@ package org.apache.myrmidon.interfaces.service; * @version $Revision$ $Date$ */ public class AntServiceException - extends Exception + extends ComponentException { /** - * The Throwable that caused this exception to be thrown. - */ - private final Throwable m_throwable; - - /** - * Basic constructor for exception that does not specify a message - */ - public AntServiceException() - { - this( "", null ); - } - - /** - * Basic constructor with a message + * Constructs a non-cascaded exception. * - * @param message the message + * @param message The detail message for this exception. */ public AntServiceException( final String message ) - { - this( message, null ); - } - - /** - * Constructor that builds cascade so that other exception information can be retained. - * - * @param message the message - * @param throwable the throwable - */ - public AntServiceException( final String message, final Throwable throwable ) { super( message ); - m_throwable = throwable; } /** - * Retrieve root cause of the exception. + * Constructs a cascaded exception. * - * @return the root cause + * @param message The detail message for this exception. + * @param throwable the root cause of the exception */ - public final Throwable getCause() + public AntServiceException( final String message, final Throwable throwable ) { - return m_throwable; + super( message, throwable ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/TypeException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/TypeException.java index ce12251c9..416ed5aa1 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/TypeException.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/TypeException.java @@ -7,6 +7,8 @@ */ package org.apache.myrmidon.interfaces.type; +import org.apache.myrmidon.interfaces.ComponentException; + /** * Exception to indicate problem with type instantiating. * @@ -14,42 +16,26 @@ package org.apache.myrmidon.interfaces.type; * @version $Revision$ $Date$ */ public final class TypeException - extends Exception + extends ComponentException { /** - * The Throwable that caused this exception to be thrown. - */ - private final Throwable m_throwable; - - /** - * Construct a new TypeException instance. + * Constructs a non-cascaded exception. * * @param message The detail message for this exception. */ public TypeException( final String message ) { - this( message, null ); + super( message ); } /** - * Construct a new TypeException instance. + * Constructs a cascaded exception. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public TypeException( final String message, final Throwable throwable ) { - super( message ); - m_throwable = throwable; - } - - /** - * Retrieve root cause of the exception. - * - * @return the root cause - */ - public final Throwable getCause() - { - return m_throwable; + super( message, throwable ); } }