Author: dallen6
Date: 2009-12-09 21:25:51 -0500 (Wed, 09 Dec 2009)
New Revision: 5261
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/AmbiguousResolutionException.java
core/trunk/impl/src/main/java/org/jboss/weld/CreationException.java
core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java
core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java
core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java
core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java
core/trunk/impl/src/main/java/org/jboss/weld/IllegalProductException.java
core/trunk/impl/src/main/java/org/jboss/weld/InconsistentSpecializationException.java
core/trunk/impl/src/main/java/org/jboss/weld/InjectionException.java
core/trunk/impl/src/main/java/org/jboss/weld/InvalidObjectException.java
core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java
core/trunk/impl/src/main/java/org/jboss/weld/NullInstanceException.java
core/trunk/impl/src/main/java/org/jboss/weld/NullableDependencyException.java
core/trunk/impl/src/main/java/org/jboss/weld/UnproxyableResolutionException.java
core/trunk/impl/src/main/java/org/jboss/weld/UnsatisfiedResolutionException.java
core/trunk/impl/src/main/java/org/jboss/weld/UnserializableDependencyException.java
core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java
Log:
Initial refactoring of exception classes
Modified: core/trunk/impl/src/main/java/org/jboss/weld/AmbiguousResolutionException.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/AmbiguousResolutionException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++
core/trunk/impl/src/main/java/org/jboss/weld/AmbiguousResolutionException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -33,11 +33,24 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public AmbiguousResolutionException(Throwable throwable)
{
super(throwable.getLocalizedMessage(), throwable);
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> AmbiguousResolutionException(E key, Object...
args)
{
super(messageConveyer.getMessage(key, args));
Modified: core/trunk/impl/src/main/java/org/jboss/weld/CreationException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/CreationException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/CreationException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -35,11 +35,28 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> CreationException(E key, Object... args)
{
super(messageConveyer.getMessage(key, args));
}
+ /**
+ * Creates a new exception with the given localized message key, the cause
+ * for this exception and optional arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param throwable The cause for this exception
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> CreationException(E key, Throwable throwable,
Object... args)
{
super(messageConveyer.getMessage(key, args), throwable);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -16,87 +16,64 @@
*/
package org.jboss.weld;
-import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
-
import java.util.List;
-import ch.qos.cal10n.IMessageConveyor;
-
/**
* Thrown if the definition of a bean is incorrect
*
* @author Pete Muir
*/
-public class DefinitionException extends RuntimeException
+public class DefinitionException extends WeldException
{
private static final long serialVersionUID = 8014646336322875707L;
- // Exception messages
- private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
-
- private String message = null;
-
- public DefinitionException()
- {
- super();
- }
-
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> DefinitionException(E key, Object... args)
{
- super();
- this.message = messageConveyer.getMessage(key, args);
+ super(key, args);
}
+ /**
+ * Creates a new exception with the given localized message key, the cause
+ * for this exception and optional arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param throwable The cause for this exception
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> DefinitionException(E key, Throwable throwable,
Object... args)
{
super(throwable);
- this.message = messageConveyer.getMessage(key, args);
}
- public DefinitionException(String message, Throwable throwable)
- {
- super(throwable);
- this.message = message;
- }
-
- public DefinitionException(String message)
- {
- super();
- this.message = message;
- }
-
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public DefinitionException(Throwable throwable)
{
super(throwable);
- this.message = throwable.getLocalizedMessage();
}
-
+
+ /**
+ * Creates a new exception based on a list of throwables. The throwables are not
+ * used as the cause, but the message from each throwable is included as the message
+ * for this exception.
+ *
+ * @param errors A list of throwables to use in the message
+ */
public DefinitionException(List<Throwable> errors)
{
- super();
- StringBuilder errorMessage = new StringBuilder();
- boolean firstError = true;
- for (Throwable throwable : errors)
- {
- if (!firstError)
- {
- errorMessage.append('\n');
- }
- errorMessage.append(throwable.getLocalizedMessage());
- }
- message = errorMessage.toString();
+ super(errors);
}
- @Override
- public String getLocalizedMessage()
- {
- return getMessage();
- }
-
- @Override
- public String getMessage()
- {
- return message;
- }
-
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -16,87 +16,68 @@
*/
package org.jboss.weld;
-import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
-
import java.util.List;
-import ch.qos.cal10n.IMessageConveyor;
-
/**
* Thrown if an deployment exception occurs.
*
* @author Pete Muir
*/
-public class DeploymentException extends RuntimeException
+public class DeploymentException extends WeldException
{
private static final long serialVersionUID = 8014646336322875707L;
- // Exception messages
- private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
-
- private String message = null;
-
public DeploymentException()
{
super();
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> DeploymentException(E key, Object... args)
{
- super();
- this.message = messageConveyer.getMessage(key, args);
+ super(key, args);
}
+ /**
+ * Creates a new exception with the given localized message key, the cause
+ * for this exception and optional arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param throwable The cause for this exception
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> DeploymentException(E key, Throwable throwable,
Object... args)
{
- super(throwable);
- this.message = messageConveyer.getMessage(key, args);
+ super(key, throwable, args);
}
- public DeploymentException(String message, Throwable throwable)
- {
- super(throwable);
- this.message = message;
- }
-
- public DeploymentException(String message)
- {
- super();
- this.message = message;
- }
-
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public DeploymentException(Throwable throwable)
{
super(throwable);
- this.message = throwable.getLocalizedMessage();
}
+ /**
+ * Creates a new exception based on a list of throwables. The throwables are not
+ * used as the cause, but the message from each throwable is included as the message
+ * for this exception.
+ *
+ * @param errors A list of throwables to use in the message
+ */
public DeploymentException(List<Throwable> errors)
{
- super();
- StringBuilder errorMessage = new StringBuilder();
- boolean firstError = true;
- for (Throwable throwable : errors)
- {
- if (!firstError)
- {
- errorMessage.append('\n');
- }
- errorMessage.append(throwable.getLocalizedMessage());
- }
- message = errorMessage.toString();
+ super(errors);
}
-
- @Override
- public String getLocalizedMessage()
- {
- return getMessage();
- }
-
- @Override
- public String getMessage()
- {
- return message;
- }
-
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++
core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -34,11 +34,24 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public ForbiddenArgumentException(Throwable throwable)
{
super(throwable.getLocalizedMessage(), throwable);
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> ForbiddenArgumentException(E key, Object...
args)
{
super(messageConveyer.getMessage(key, args));
Modified: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -33,11 +33,24 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> ForbiddenStateException(E key, Object... args)
{
super(messageConveyer.getMessage(key, args));
}
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public ForbiddenStateException(Throwable cause)
{
super(cause.getLocalizedMessage(), cause);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/IllegalProductException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/IllegalProductException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/IllegalProductException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -35,6 +35,14 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> IllegalProductException(E key, Object... args)
{
super(messageConveyer.getMessage(key, args));
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/InconsistentSpecializationException.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/InconsistentSpecializationException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++
core/trunk/impl/src/main/java/org/jboss/weld/InconsistentSpecializationException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -16,8 +16,6 @@
*/
package org.jboss.weld;
-import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
-import ch.qos.cal10n.IMessageConveyor;
/**
*
@@ -28,32 +26,27 @@
private static final long serialVersionUID = 4359656880524913555L;
- // Exception messages
- private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
-
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> InconsistentSpecializationException(E key,
Object... args)
{
- super(messageConveyer.getMessage(key, args));
+ super(key, args);
}
- public InconsistentSpecializationException()
- {
- super();
- }
-
- public InconsistentSpecializationException(String message, Throwable throwable)
- {
- super(message, throwable);
- }
-
- public InconsistentSpecializationException(String message)
- {
- super(message);
- }
-
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public InconsistentSpecializationException(Throwable throwable)
{
- super(throwable.getLocalizedMessage(), throwable);
+ super(throwable);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/InjectionException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/InjectionException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/InjectionException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -33,16 +33,37 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public InjectionException(Throwable throwable)
{
super(throwable.getLocalizedMessage(), throwable);
}
+ /**
+ * Creates a new exception with an arbitrary message and the cause of the
+ * exception. It is not recommended to use this constructor since the
+ * message cannot be localized.
+ *
+ * @param message The error message
+ * @param throwable The cause of the exception or wrapped throwable
+ */
public InjectionException(String message, Throwable throwable)
{
super(message, throwable);
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> InjectionException(E key, Object... args)
{
super(messageConveyer.getMessage(key, args));
Modified: core/trunk/impl/src/main/java/org/jboss/weld/InvalidObjectException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/InvalidObjectException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/InvalidObjectException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -35,6 +35,14 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> InvalidObjectException(E key, Object... args)
{
super(messageConveyer.getMessage(key, args));
Modified: core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -35,11 +35,22 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Default constructor mostly for serialization purposes.
+ */
public InvalidOperationException()
{
super();
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> InvalidOperationException(E key, Object...
args)
{
super(messageConveyer.getMessage(key, args));
Modified: core/trunk/impl/src/main/java/org/jboss/weld/NullInstanceException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/NullInstanceException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/NullInstanceException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -30,6 +30,14 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> NullInstanceException(E key, Object... args)
{
super(key, args);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/NullableDependencyException.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/NullableDependencyException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++
core/trunk/impl/src/main/java/org/jboss/weld/NullableDependencyException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -16,8 +16,6 @@
*/
package org.jboss.weld;
-import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
-import ch.qos.cal10n.IMessageConveyor;
/**
* Thrown if an injection point of primitive type resolves to a bean which may
@@ -30,29 +28,24 @@
private static final long serialVersionUID = 6877485218767005761L;
- // Exception messages
- private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
-
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> NullableDependencyException(E key, Object...
args)
{
- super(messageConveyer.getMessage(key, args));
+ super(key, args);
}
- public NullableDependencyException()
- {
- super();
- }
-
- public NullableDependencyException(String message, Throwable throwable)
- {
- super(message, throwable);
- }
-
- public NullableDependencyException(String message)
- {
- super(message);
- }
-
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public NullableDependencyException(Throwable throwable)
{
super(throwable);
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/UnproxyableResolutionException.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/UnproxyableResolutionException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++
core/trunk/impl/src/main/java/org/jboss/weld/UnproxyableResolutionException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -33,11 +33,24 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public UnproxyableResolutionException(Throwable throwable)
{
super(throwable.getLocalizedMessage(), throwable);
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> UnproxyableResolutionException(E key, Object...
args)
{
super(messageConveyer.getMessage(key, args));
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/UnsatisfiedResolutionException.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/UnsatisfiedResolutionException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++
core/trunk/impl/src/main/java/org/jboss/weld/UnsatisfiedResolutionException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -34,11 +34,24 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public UnsatisfiedResolutionException(Throwable throwable)
{
super(throwable.getLocalizedMessage(), throwable);
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> UnsatisfiedResolutionException(E key, Object...
args)
{
super(messageConveyer.getMessage(key, args));
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/UnserializableDependencyException.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/UnserializableDependencyException.java 2009-12-09
22:56:14 UTC (rev 5260)
+++
core/trunk/impl/src/main/java/org/jboss/weld/UnserializableDependencyException.java 2009-12-10
02:25:51 UTC (rev 5261)
@@ -16,8 +16,6 @@
*/
package org.jboss.weld;
-import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
-import ch.qos.cal10n.IMessageConveyor;
/**
@@ -33,29 +31,24 @@
private static final long serialVersionUID = -6287506607413810688L;
- // Exception messages
- private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
-
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> UnserializableDependencyException(E key,
Object... args)
{
- super(messageConveyer.getMessage(key, args));
+ super(key, args);
}
- public UnserializableDependencyException()
- {
- super();
- }
-
- public UnserializableDependencyException(String message, Throwable throwable)
- {
- super(message, throwable);
- }
-
- public UnserializableDependencyException(String message)
- {
- super(message);
- }
-
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public UnserializableDependencyException(Throwable throwable)
{
super(throwable);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/Validator.java 2009-12-09 22:56:14 UTC
(rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/Validator.java 2009-12-10 02:25:51 UTC
(rev 5261)
@@ -20,6 +20,8 @@
import static
org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_BEAN_CLASS_SPECIFIED_MULTIPLE_TIMES;
import static
org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_STEREOTYPE_NOT_ANNOTATED;
import static
org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_STEREOTYPE_SPECIFIED_MULTIPLE_TIMES;
+import static org.jboss.weld.logging.messages.ValidatorMessage.AMBIGUOUS_EL_NAME;
+import static org.jboss.weld.logging.messages.ValidatorMessage.BEAN_NAME_IS_PREFIX;
import static
org.jboss.weld.logging.messages.ValidatorMessage.BEAN_SPECIALIZED_TOO_MANY_TIMES;
import static
org.jboss.weld.logging.messages.ValidatorMessage.DECORATOR_CLASS_NOT_BEAN_CLASS_OF_DECORATOR;
import static
org.jboss.weld.logging.messages.ValidatorMessage.DECORATOR_SPECIFIED_TWICE;
@@ -338,11 +340,11 @@
Set<Bean<?>> resolvedBeans =
beanManager.getBeanResolver().resolve(namedAccessibleBeans.get(name));
if (resolvedBeans.size() > 1)
{
- throw new DeploymentException("An unresolvable ambiguous EL name exists
for " + name + "; found " + resolvedBeans );
+ throw new DeploymentException(AMBIGUOUS_EL_NAME, name, resolvedBeans );
}
if (accessibleNamespaces.contains(name))
{
- throw new DeploymentException("The bean name " + name + " is
used as a prefix for another bean");
+ throw new DeploymentException(BEAN_NAME_IS_PREFIX, name);
}
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java 2009-12-09 22:56:14
UTC (rev 5260)
+++ core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java 2009-12-10 02:25:51
UTC (rev 5261)
@@ -18,6 +18,9 @@
package org.jboss.weld;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+
+import java.util.List;
+
import ch.qos.cal10n.IMessageConveyor;
/**
@@ -32,19 +35,94 @@
// Exception messages
private static final IMessageConveyor messageConveyer =
loggerFactory().getMessageConveyor();
+ private String message = null;
+
+ /**
+ * Default constructor mostly for serialization purposes.
+ */
+ protected WeldException()
+ {
+ super();
+ }
+
+ /**
+ * Creates a new exception with the given cause.
+ *
+ * @param throwable The cause of the exception
+ */
public WeldException(Throwable throwable)
{
super(throwable.getLocalizedMessage(), throwable);
+ this.message = throwable.getLocalizedMessage();
}
+ /**
+ * Creates a new exception with the given localized message key and optional
+ * arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> WeldException(E key, Object... args)
{
super(messageConveyer.getMessage(key, args));
+ this.message = messageConveyer.getMessage(key, args);
}
+ /**
+ * Creates a new exception with the given localized message key, the cause
+ * for this exception and optional arguments for the message.
+ *
+ * @param <E> The enumeration type for the message keys
+ * @param key The localized message to use
+ * @param throwable The cause for this exception
+ * @param args Optional arguments to insert into the message
+ */
public <E extends Enum<?>> WeldException(E key, Throwable throwable,
Object... args)
{
super(messageConveyer.getMessage(key, args), throwable);
+ this.message = messageConveyer.getMessage(key, args);
}
+ /**
+ * Creates a new exception based on a list of throwables. The throwables are not
+ * used as the cause, but the message from each throwable is included as the message
+ * for this exception.
+ *
+ * @param errors A list of throwables to use in the message
+ */
+ public WeldException(List<Throwable> errors)
+ {
+ super();
+ StringBuilder errorMessage = new StringBuilder();
+ boolean firstError = true;
+ for (Throwable throwable : errors)
+ {
+ if (!firstError)
+ {
+ errorMessage.append('\n');
+ }
+ errorMessage.append(throwable.getLocalizedMessage());
+ }
+ setMessage(errorMessage.toString());
+ }
+
+ protected void setMessage(String message)
+ {
+ this.message = message;
+ }
+
+ @Override
+ public String getLocalizedMessage()
+ {
+ return getMessage();
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return message;
+ }
+
}