diff --git a/groovy/src/main/com/nvuillam/CodeNarcServer.groovy b/groovy/src/main/com/nvuillam/CodeNarcServer.groovy index 8cda130e..19968cd4 100644 --- a/groovy/src/main/com/nvuillam/CodeNarcServer.groovy +++ b/groovy/src/main/com/nvuillam/CodeNarcServer.groovy @@ -194,7 +194,7 @@ class CodeNarcServer { WRITER.writeValue(out, response) } } catch (Exception e) { - LOGGER.error('Write response {}', e) + LOGGER.error('Write response', e) } finally { if (requestKey) { threads.remove(requestKey) diff --git a/groovy/src/main/com/nvuillam/Request.groovy b/groovy/src/main/com/nvuillam/Request.groovy index b69524a5..0c9ef01a 100644 --- a/groovy/src/main/com/nvuillam/Request.groovy +++ b/groovy/src/main/com/nvuillam/Request.groovy @@ -145,8 +145,8 @@ class Request { * @param fileList the list of files to parse * @return the map of files to errors */ - private Map> parseFiles(List fileList) { - Map> parseErrors = [:] + private Map> parseFiles(List fileList) { + Map> parseErrors = [:] LOGGER.debug('parseFiles: parse={}, fileList={}', parse, fileList) if (parse) { fileList.each { file -> @@ -210,8 +210,21 @@ class Request { return files } - // Try to parse file to get compilation errors - private List parseFile(File file) { + // Try to parse file to get compilation errors as strings. + private List parseFile(File file) { + List errors = [] + for (err in parseFileErrors(file)) { + StringWriter out = new StringWriter(); + PrintWriter writer = new PrintWriter(out); + err.write(writer) + errors << out.toString() + } + + return errors + } + + // Try to parse file to get compilation errors. + private List parseFileErrors(File file) { try { // We don't use GroovyShell.parse as it calls InvokerHelper.createScript // which fails for files which contain a class which only have non-zero diff --git a/groovy/src/main/com/nvuillam/Response.groovy b/groovy/src/main/com/nvuillam/Response.groovy index 072b1f07..b66d41f7 100644 --- a/groovy/src/main/com/nvuillam/Response.groovy +++ b/groovy/src/main/com/nvuillam/Response.groovy @@ -23,7 +23,7 @@ class Response { String errorMessage String errorDtl String exceptionType - Map> parseErrors + Map> parseErrors // Lint result. @JsonRawValue diff --git a/lib/java/CodeNarcServer.jar b/lib/java/CodeNarcServer.jar index d54890c3..15575f5a 100644 Binary files a/lib/java/CodeNarcServer.jar and b/lib/java/CodeNarcServer.jar differ