Skip to content

Commit 4a9e269

Browse files
committed
Improve error reporting within the GrEclipse step.
1 parent fea35e6 commit 4a9e269

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib-extra/src/groovy/java/com/diffplug/spotless/extra/glue/groovy/GrEclipseFormatterStepImpl.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ public String format(String raw) throws Exception {
104104
* Eclipse Groovy formatter does not signal problems by its return value, but by logging errors.
105105
*/
106106
private static final class GroovyErrorListener implements ILogListener, IGroovyLogger {
107-
private final List<String> errors;
107+
private final List<Throwable> errors;
108108

109109
public GroovyErrorListener() {
110110
/*
111111
* We need a synchronized list here, in case multiple instantiations
112112
* run in parallel.
113113
*/
114-
errors = Collections.synchronizedList(new ArrayList<String>());
114+
errors = Collections.synchronizedList(new ArrayList<>());
115115
ILog groovyLogger = GroovyCoreActivator.getDefault().getLog();
116116
groovyLogger.addLogListener(this);
117117
synchronized (GroovyLogManager.manager) {
@@ -121,7 +121,7 @@ public GroovyErrorListener() {
121121

122122
@Override
123123
public void logging(final IStatus status, final String plugin) {
124-
errors.add(status.getMessage());
124+
errors.add(status.getException());
125125
}
126126

127127
public boolean errorsDetected() {
@@ -141,9 +141,10 @@ public String toString() {
141141
} else if (0 == errors.size()) {
142142
string.append("Step sucesfully executed.");
143143
}
144-
for (String error : errors) {
144+
for (Throwable error : errors) {
145+
error.printStackTrace();
145146
string.append(System.lineSeparator());
146-
string.append(error);
147+
string.append(error.getMessage());
147148
}
148149

149150
return string.toString();
@@ -162,7 +163,11 @@ public boolean isCategoryEnabled(TraceCategory cat) {
162163

163164
@Override
164165
public void log(TraceCategory arg0, String arg1) {
165-
errors.add(arg1);
166+
try {
167+
throw new RuntimeException(arg1);
168+
} catch (RuntimeException e) {
169+
errors.add(e);
170+
}
166171
}
167172
}
168173

0 commit comments

Comments
 (0)