我在打印 Alfresco 异常的异常堆栈跟踪时遇到一些问题。
在 Debug模式下,在 Eclipse IDE 下一步一步地,当引发异常时检查 Exception 对象,我能够看到消息,但是,当我将错误消息发送到控制台输出时,它始终为 null。
此指令引发异常:
try {
UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
}
catch (Exception ex) {
System.out.println(" " + ex.getStackTrace());
System.out.println("ERROR - createContent : " + ex.getMessage());
}
(在这种情况下,我尝试写入存储库中不存在的文件夹)并检查 eclipse 上的 ex 对象,我可以看到消息:
java.lang.IllegalStateException: Failed to resolve to a single NodeRef with parameters (store=workspace:SpacesStore uuid=null path=/app:company_home/cm:UploadFromJava), found 0 nodes.
但是 ex.getMessage() 返回 null
有人可以帮助我吗?
谢谢, 安德里亚
最佳答案
以这种方式实现方法:
NamedValue setNameProperty(String name) throws AlfrescoRuntimeException
{
try {
return Utils.createNamedValue(Constants.PROP_NAME, name);
}
catch (Exception ex) {
throw new AlfrescoRuntimeException(ex.getMessage());
}
}
使用 e.printStackTrace() 正确打印消息;
关于java - 打印露天异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7576439/