Log stack trace when exception is thrown in a ViewTool
Currently when an exception occurs in a ViewTool, dotCMS logs the following:
ERROR viewtool.MyViewTool: someViewToolMethod
The exception is however swallowed by the method that logs this line, and it is extremely hard to debug these cases, especially for unchecked exceptions. It would make the lifes of plugin developers a lot easier when the stack trace will also be logged, like:
ERROR viewtool.MyViewTool: someViewToolMethod
java.lang.NullPointerException
at foo.bar.Class(Class.java:123
at ...
This can easily be changed in com.dotmarketing.velocity.events.MethodExceptionEventHandlerImpl.methodException(clazz, message, e) by adding the exception to the Logger.error statement. The exception is after all already available.
The complete method would then look like:
``` java public Object methodException(Class clazz, String message, Exception e) throws Exception {
if \(!isEditMode\(e\)\) {
Logger.error\(clazz, message, e\);
return null;
}
String x = e.toString\(\);
if \(e instanceof ParseErrorException\) {
x = getParseErrorMessage\(\(ParseErrorException\) e\);
}
else if\(e instanceof com.dotcms.repackage.org.apache.lucene.queryparser.classic.ParseException\){
x = getLuceneParseErrorMessage\(\(com.dotcms.repackage.org.apache.lucene.queryparser.classic.ParseException\) e\);
}
else {
x = getErrorMessage\( e\);
}
return x;
}
```
This seems like a no-brainer with regard to the actual fix (adding the 'e' argument to Logger.error()).
When will this be fixed?
This issue has been automatically marked as stale because it has not had activity within the past 90 days. It will be closed in 30 days no further activity occurs. Thank you.