Those terrible error messages
dmlloyd Jan 28, 2009 10:22 AMOne of the most off-putting things about JBossMC is the confusing, non-human error messages it produces when a deployment fails. Carlo's thread gave me the notion to try and fix this. Here's the patch to AbstractKernelDeployer which humanizes the error message. What do you think? Should I commit it?
Index: kernel/src/main/java/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java
===================================================================
--- kernel/src/main/java/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java
+++ kernel/src/main/java/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java
@@ -217,22 +217,21 @@
buffer.append("Incompletely deployed:\n");
if (errors.size() != 0)
{
- buffer.append("\n*** DEPLOYMENTS IN ERROR: Name -> Error\n");
+ buffer.append("\nDEPLOYMENTS IN ERROR:\n");
for (ControllerContext ctx : errors)
{
- buffer.append(ctx.getName()).append(" -> ").append(ctx.getError().toString()).append('\n');
+ buffer.append(String.format(" Deployment \"%s\" is in error due to: %s\n", ctx.getName(), ctx.getError()));
}
}
if (incomplete.size() != 0)
{
- buffer.append("\n*** DEPLOYMENTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}\n");
+ buffer.append("\nDEPLOYMENTS MISSING DEPENDENCIES:\n");
for (ControllerContext ctx : incomplete)
{
Object name = ctx.getName();
- buffer.append(name).append(" -> ");
+ buffer.append(String.format(" Deployment \"%s\" is missing the following dependencies:\n", name));
DependencyInfo dependsInfo = ctx.getDependencyInfo();
Set<DependencyItem> depends = dependsInfo.getIDependOn(null);
- boolean first = true;
for (DependencyItem item : depends)
{
ControllerState dependentState = item.getDependentState();
@@ -262,29 +261,18 @@
if (print)
{
- if (first)
- first = false;
- else
- buffer.append(", ");
-
- buffer.append(iDependOn).append('{').append(dependentState.getStateString());
- buffer.append(':');
- if (iDependOn == null)
- {
- buffer.append("** UNRESOLVED " + item.toHumanReadableString() + " **");
- }
- else
- {
- if (other == null)
- buffer.append("** NOT FOUND **");
- else
- buffer.append(otherState.getStateString());
- }
- buffer.append('}');
+ buffer.append(String.format(" Dependency \"%s\" (should be in state \"%s\", but is actually %s)\n",
+ iDependOn,
+ dependentState.getStateString(),
+ iDependOn == null ?
+ String.format("unresolved (%s)",
+ item.toHumanReadableString()) :
+ other == null ?
+ "not found" :
+ String.format("in state \"%s\"", otherState.getStateString())));
}
}
}
- buffer.append('\n');
}
}
throw new IllegalStateException(buffer.toString());