Browse Source

Decouple exceptions from CascadingException

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271633 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
357537149c
12 changed files with 181 additions and 82 deletions
  1. +1
    -15
      proposal/myrmidon/src/java/org/apache/antlib/core/Property.java
  2. +18
    -4
      proposal/myrmidon/src/java/org/apache/aut/converter/ConverterException.java
  3. +18
    -4
      proposal/myrmidon/src/java/org/apache/aut/manifest/ManifestException.java
  4. +18
    -4
      proposal/myrmidon/src/java/org/apache/aut/nativelib/ExecException.java
  5. +26
    -10
      proposal/myrmidon/src/java/org/apache/aut/vfs/FileSystemException.java
  6. +18
    -4
      proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskException.java
  7. +5
    -7
      proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  8. +1
    -15
      proposal/myrmidon/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java
  9. +18
    -4
      proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/deployer/DeploymentException.java
  10. +22
    -7
      proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleException.java
  11. +18
    -4
      proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/service/AntServiceException.java
  12. +18
    -4
      proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/TypeException.java

+ 1
- 15
proposal/myrmidon/src/java/org/apache/antlib/core/Property.java View File

@@ -10,7 +10,6 @@ package org.apache.antlib.core;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.DataType;

@@ -31,18 +30,12 @@ public class Property

private String m_name;
private Object m_value;
private boolean m_localScope = true;

public void setName( final String name )
{
m_name = name;
}

public void setLocalScope( final boolean localScope )
{
m_localScope = localScope;
}

/**
* Sets the property value from a nested element.
*/
@@ -91,13 +84,6 @@ public class Property
throw new TaskException( message );
}

if( m_localScope )
{
getContext().setProperty( m_name, m_value );
}
else
{
getContext().setProperty( m_name, m_value, TaskContext.PARENT );
}
getContext().setProperty( m_name, m_value );
}
}

+ 18
- 4
proposal/myrmidon/src/java/org/apache/aut/converter/ConverterException.java View File

@@ -7,8 +7,6 @@
*/
package org.apache.aut.converter;

import org.apache.avalon.framework.CascadingException;

/**
* ConverterException thrown when a problem occurs during convertion etc.
*
@@ -16,8 +14,13 @@ import org.apache.avalon.framework.CascadingException;
* @version $Revision$ $Date$
*/
public class ConverterException
extends CascadingException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Basic constructor with a message
*
@@ -36,7 +39,18 @@ public class ConverterException
*/
public ConverterException( final String message, final Throwable throwable )
{
super( message, throwable );
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}


+ 18
- 4
proposal/myrmidon/src/java/org/apache/aut/manifest/ManifestException.java View File

@@ -7,8 +7,6 @@
*/
package org.apache.aut.manifest;

import org.apache.avalon.framework.CascadingException;

/**
* ManifestException is thrown when there is a problem parsing, generating or
* handling a Manifest.
@@ -17,8 +15,13 @@ import org.apache.avalon.framework.CascadingException;
* @version $Revision$ $Date$
*/
public class ManifestException
extends CascadingException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Basic constructor for exception that does not specify a message
*/
@@ -45,6 +48,17 @@ public class ManifestException
*/
public ManifestException( final String message, final Throwable throwable )
{
super( message, throwable );
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}

+ 18
- 4
proposal/myrmidon/src/java/org/apache/aut/nativelib/ExecException.java View File

@@ -7,16 +7,19 @@
*/
package org.apache.aut.nativelib;

import org.apache.avalon.framework.CascadingException;

/**
* ExecException indicates there was an error executing native process.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
*/
public class ExecException
extends CascadingException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Basic constructor for exception that does not specify a message
*/
@@ -43,7 +46,18 @@ public class ExecException
*/
public ExecException( final String message, final Throwable throwable )
{
super( message, throwable );
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}


+ 26
- 10
proposal/myrmidon/src/java/org/apache/aut/vfs/FileSystemException.java View File

@@ -7,33 +7,49 @@
*/
package org.apache.aut.vfs;

import org.apache.avalon.framework.CascadingException;

/**
* Thrown for file system errors.
*
* @author Adam Murdoch
*/
public class FileSystemException extends CascadingException
public class FileSystemException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Constructs exception with the specified detail message.
*
* @param msg the detail message.
* @param message the detail message.
*/
public FileSystemException( String msg )
public FileSystemException( final String message )
{
super( msg );
this( message, null );
}

/**
* Constructs exception with the specified detail message.
*
* @param msg the detail message.
* @param cause the cause.
* @param message the detail message.
* @param throwable the cause.
*/
public FileSystemException( final String message,
final Throwable throwable )
{
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public FileSystemException( String msg, Throwable cause )
public final Throwable getCause()
{
super( msg, cause );
return m_throwable;
}
}

+ 18
- 4
proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskException.java View File

@@ -7,8 +7,6 @@
*/
package org.apache.myrmidon.api;

import org.apache.avalon.framework.CascadingException;

/**
* TaskException thrown when a problem with tasks etc.
* It is cascading so that further embedded information can be contained.
@@ -18,8 +16,13 @@ import org.apache.avalon.framework.CascadingException;
* @version $Revision$ $Date$
*/
public class TaskException
extends CascadingException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Basic constructor for exception that does not specify a message
*/
@@ -46,7 +49,18 @@ public class TaskException
*/
public TaskException( final String message, final Throwable throwable )
{
super( message, throwable );
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}


+ 5
- 7
proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java View File

@@ -17,7 +17,6 @@ import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.excalibur.util.StringUtil;
import org.apache.avalon.framework.CascadingException;
import org.apache.avalon.framework.Version;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -57,7 +56,6 @@ public class DefaultProjectBuilder
*
* @param source the source
* @return the constructed Project
* @exception IOException if an error occurs
* @exception Exception if an error occurs
*/
public Project build( final String source )
@@ -115,7 +113,7 @@ public class DefaultProjectBuilder
* @param file the file from which configuration was loaded
* @param configuration the configuration loaded
* @return the created Project
* @exception IOException if an error occurs
* @exception Exception if an error occurs
* @exception Exception if an error occurs
* @exception ConfigurationException if an error occurs
*/
@@ -172,7 +170,7 @@ public class DefaultProjectBuilder
* Throw exceptions with meaningful errors if malformed or missing.
*/
private Version getVersion( final Configuration configuration )
throws CascadingException
throws Exception
{
try
{
@@ -182,7 +180,7 @@ public class DefaultProjectBuilder
catch( final ConfigurationException ce )
{
final String message = REZ.getString( "ant.version-missing.error" );
throw new CascadingException( message, ce );
throw new ConfigurationException( message, ce );
}
}

@@ -190,7 +188,7 @@ public class DefaultProjectBuilder
* Utility function to extract version
*/
private Version parseVersion( final String versionString )
throws CascadingException
throws Exception
{

try
@@ -202,7 +200,7 @@ public class DefaultProjectBuilder
final String message =
REZ.getString( "ant.malformed.version", versionString );
getLogger().warn( message );
throw new CascadingException( message, e );
throw new ConfigurationException( message, e );
}
}



+ 1
- 15
proposal/myrmidon/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java View File

@@ -13,7 +13,6 @@ import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;

/**
@@ -31,7 +30,6 @@ public class TypeInstanceTask

private String m_id;
private Object m_value;
private boolean m_localScope = true;

public void configure( final Configuration configuration )
throws ConfigurationException
@@ -79,11 +77,6 @@ public class TypeInstanceTask
m_id = id;
}

public void setLocalScope( final boolean localScope )
{
m_localScope = localScope;
}

public void execute()
throws TaskException
{
@@ -93,13 +86,6 @@ public class TypeInstanceTask
throw new TaskException( message );
}

if( m_localScope )
{
getContext().setProperty( m_id, m_value );
}
else
{
getContext().setProperty( m_id, m_value, TaskContext.PARENT );
}
getContext().setProperty( m_id, m_value );
}
}

+ 18
- 4
proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/deployer/DeploymentException.java View File

@@ -7,8 +7,6 @@
*/
package org.apache.myrmidon.interfaces.deployer;

import org.apache.avalon.framework.CascadingException;

/**
* Exception to indicate error deploying.
*
@@ -16,8 +14,13 @@ import org.apache.avalon.framework.CascadingException;
* @version $Revision$ $Date$
*/
public final class DeploymentException
extends CascadingException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Construct a new <code>DeploymentException</code> instance.
*
@@ -36,6 +39,17 @@ public final class DeploymentException
*/
public DeploymentException( final String message, final Throwable throwable )
{
super( message, throwable );
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}

+ 22
- 7
proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleException.java View File

@@ -7,8 +7,6 @@
*/
package org.apache.myrmidon.interfaces.role;

import org.apache.avalon.framework.CascadingException;

/**
* An exception thrown by the RoleManager.
*
@@ -16,15 +14,32 @@ import org.apache.avalon.framework.CascadingException;
* @version $Revision$ $Date$
*/
public class RoleException
extends CascadingException
extends Exception
{
public RoleException( String s )
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

public RoleException( final String message )
{
this( message, null );
}

public RoleException( final String message,
final Throwable throwable )
{
super( s );
super( message );
m_throwable = throwable;
}

public RoleException( String s, Throwable throwable )
/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
super( s, throwable );
return m_throwable;
}
}

+ 18
- 4
proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/service/AntServiceException.java View File

@@ -7,8 +7,6 @@
*/
package org.apache.myrmidon.interfaces.service;

import org.apache.avalon.framework.CascadingException;

/**
* ServiceException thrown when a service can not be created for
* some reason.
@@ -17,8 +15,13 @@ import org.apache.avalon.framework.CascadingException;
* @version $Revision$ $Date$
*/
public class AntServiceException
extends CascadingException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Basic constructor for exception that does not specify a message
*/
@@ -45,7 +48,18 @@ public class AntServiceException
*/
public AntServiceException( final String message, final Throwable throwable )
{
super( message, throwable );
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}


+ 18
- 4
proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/TypeException.java View File

@@ -7,8 +7,6 @@
*/
package org.apache.myrmidon.interfaces.type;

import org.apache.avalon.framework.CascadingException;

/**
* Exception to indicate problem with type instantiating.
*
@@ -16,8 +14,13 @@ import org.apache.avalon.framework.CascadingException;
* @version $Revision$ $Date$
*/
public final class TypeException
extends CascadingException
extends Exception
{
/**
* The Throwable that caused this exception to be thrown.
*/
private final Throwable m_throwable;

/**
* Construct a new <code>TypeException</code> instance.
*
@@ -36,6 +39,17 @@ public final class TypeException
*/
public TypeException( final String message, final Throwable throwable )
{
super( message, throwable );
super( message );
m_throwable = throwable;
}

/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}

Loading…
Cancel
Save