You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Raible <ma...@raibledesigns.com> on 2002/12/27 09:44:13 UTC
Declared Exceptions and Chained Exceptions
Can I use Declarative Exceptions and Chained Exceptions at the same
time? I'd love to be a able to specify a list of exceptions in my
struts-config.xml, and have those errors stacked on each other.
Currently, I'm rendering ChainedExceptions using the following, and
would love to do it in struts-config.xml instead. Any advice or
suggestions are appreciated.
try {
UserManager mgr =
new UserManagerImpl(
(String) ctx.getAttribute(Constants.DAO_TYPE));
UserForm user = mgr.getUser(username);
session.setAttribute(Constants.USER_KEY, user);
} catch (Exception e) {
log.error("Error getting user's information " + e);
e.printStackTrace();
ActionErrors errors = new ActionErrors();
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("errors.general"));
StringBuffer sb = new StringBuffer();
if (e.getCause() == null) {
sb.append(e.getMessage());
} else {
while (e.getCause() != null) {
sb.append(e.getMessage());
e = (Exception) e.getCause();
}
}
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("errors.detail", sb.toString()));
}
Thanks,
Matt
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>