private RuntimeException mangleMultipleCompilationErrorsException(MultipleCompilationErrorsException e, List<StringSection> sections) { RuntimeException result = e; ErrorCollector collector = e.getErrorCollector(); @SuppressWarnings({"unchecked"}) List<Message> errors = (List<Message>) collector.getErrors(); String message = mangleExceptionMessage(e.getMessage(), errorPosition); result = new TemplateParseException(message, e, errorPosition.row, errorPosition.column);
/** * Causes the current phase to fail by throwing a * CompilationFailedException. */ protected void failIfErrors() throws CompilationFailedException { if (hasErrors()) { throw new MultipleCompilationErrorsException(this); } }
((MultipleCompilationErrorsException) t).getErrorCollector().getErrorCount() == 1) { final String errorMessage = String.format("The Gremlin statement that was submitted exceeds the maximum compilation size allowed by the JVM, please split it into multiple smaller statements - %s", trimMessage(msg)); logger.warn(errorMessage);
public FormValidation doCheckDsl(@QueryParameter String value) { // Require RUN_SCRIPTS permission, otherwise print a warning that no edits are possible if (!Jenkins.getInstance().hasPermission(Jenkins.RUN_SCRIPTS)) { return FormValidation.warning(Messages.BuildFlow_InsufficientPermissions()); } try { new GroovyShell().parse(value); } catch (MultipleCompilationErrorsException e) { return FormValidation.error( e.getMessage()); } return FormValidation.ok(); }
public CpsCompilationErrorsException(MultipleCompilationErrorsException original) { super(original.getMessage()); setStackTrace(original.getStackTrace()); }
try { new GroovyShell().parse(groovyCode); } catch(MultipleCompilationErrorsException cfe) { ErrorCollector errorCollector = cfe.getErrorCollector(); System.out.println("Errors: "+errorCollector.getErrorCount()); }
String msg = e.getMessage(); msg = msg.substring(msg.indexOf('\n') + 1); msg = msg.replaceAll("ext: ", "");
@Override public Set<PublishDiagnosticsParams> compile(Set<URI> files) { try { unit.compile(); } catch (MultipleCompilationErrorsException e) { return parseErrors(e.getErrorCollector()); } return ImmutableSet.of(); }
private RuntimeException mangleMultipleCompilationErrorsException(MultipleCompilationErrorsException e, List<StringSection> sections) { RuntimeException result = e; ErrorCollector collector = e.getErrorCollector(); @SuppressWarnings({"unchecked"}) List<Message> errors = (List<Message>) collector.getErrors(); String message = mangleExceptionMessage(e.getMessage(), errorPosition); result = new TemplateParseException(message, e, errorPosition.row, errorPosition.column);
return shell.evaluate(buffer.toString()); } catch (MultipleCompilationErrorsException err) { throw new GroovyRuntimeException("Error creating proxy: " + err.getMessage());
/** * Causes the current phase to fail by throwing a * CompilationFailedException. */ protected void failIfErrors() throws CompilationFailedException { if (hasErrors()) { throw new MultipleCompilationErrorsException(this); } }
public static List<String> errorToStrings(Exception e) { List<String> output = new ArrayList<>(); if (e instanceof MultipleCompilationErrorsException) { MultipleCompilationErrorsException ce = (MultipleCompilationErrorsException) e; for (Object o : ce.getErrorCollector().getErrors()) { if (o instanceof SyntaxErrorMessage) { SyntaxErrorMessage s = (SyntaxErrorMessage) o; StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); s.write(pw); pw.close(); output.add(sw.toString()); } } } else { output.add(e.getMessage()); } return output; } /**
private void assertImproperOverride(String methodStub) { try { sandboxedSh.evaluate(SCRIPT_HARNESS.replace("METHOD", methodStub)); fail("Should have failed"); } catch (MultipleCompilationErrorsException e) { assertThat(e.getErrorCollector().getErrorCount(), equalTo(1)); assertThat(e.getMessage(), anyOf( containsString("cannot override finalize in java.lang.Object"), containsString("incompatible with void in java.lang.Object"))); } }
return shell.evaluate(buffer.toString()); } catch (MultipleCompilationErrorsException err) { throw new GroovyRuntimeException("Error creating proxy: " + err.getMessage());
/** * Causes the current phase to fail by throwing a * CompilationFailedException. */ protected void failIfErrors() throws CompilationFailedException { if (hasErrors()) { throw new MultipleCompilationErrorsException(this); } }
private void wrapCompilationFailure(ScriptSource source, MultipleCompilationErrorsException e) { // Fix the source file name displayed in the error messages for (Object message : e.getErrorCollector().getErrors()) { if (message instanceof SyntaxErrorMessage) { try { SyntaxErrorMessage syntaxErrorMessage = (SyntaxErrorMessage) message; Field sourceField = SyntaxErrorMessage.class.getDeclaredField("source"); sourceField.setAccessible(true); SourceUnit sourceUnit = (SourceUnit) sourceField.get(syntaxErrorMessage); Field nameField = SourceUnit.class.getDeclaredField("name"); nameField.setAccessible(true); nameField.set(sourceUnit, source.getDisplayName()); } catch (Exception failure) { throw UncheckedException.throwAsUncheckedException(failure); } } } SyntaxException syntaxError = e.getErrorCollector().getSyntaxError(0); Integer lineNumber = syntaxError == null ? null : syntaxError.getLine(); throw new ScriptCompilationException(String.format("Could not compile %s.", source.getDisplayName()), e, source, lineNumber); }
return (GroovyObject) shell.evaluate(buffer.toString()); } catch (MultipleCompilationErrorsException err) { throw new GroovyRuntimeException("Error creating proxy: " + err.getMessage());
/** * Causes the current phase to fail by throwing a * CompilationFailedException. */ protected void failIfErrors() throws CompilationFailedException { if (hasErrors()) { throw new MultipleCompilationErrorsException(this); } }
public static String getSyntaxErrorReport(MultipleCompilationErrorsException e, String configName) { StringBuilder b = new StringBuilder(); b.append("Config name: "); b.append(configName); b.append("\n"); b.append("Errors:\n"); for (Object o : e.getErrorCollector().getErrors()) { if (o instanceof SyntaxErrorMessage) { b.append(" - "); b.append(((SyntaxErrorMessage) o).getCause().getMessage()); b.append("\n"); } } return b.toString(); }
return shell.evaluate(buffer.toString()); } catch (MultipleCompilationErrorsException err) { throw new GroovyRuntimeException("Error creating proxy: " + err.getMessage());