public static ScriptException unwrap(groovy.util.ScriptException cause) { // Special handling for groovy.util.ScriptException // which may be thrown by scripts because it is imported by default // by groovy imports String msg = cause.getMessage(); ScriptException translated; if (msg != null) { translated = new ScriptException(msg); } else { translated = new ScriptException(); } translated.setStackTrace(cause.getStackTrace()); return translated; }
@Command public String main() { throw new org.crsh.command.ScriptException(); } }
public void testConsumerThrowsScriptExceptionInProvide() throws Exception { String consumer = "class producer {\n" + " @Command\n" + " public org.crsh.command.Pipe<Integer, Object> main() {\n" + " return new org.crsh.command.Pipe<Integer, Object>() {\n" + " public void provide(Integer element) {\n" + " throw new org.crsh.command.ScriptException('foo')\n" + " }\n" + " };\n" + " }\n" + "}\n"; lifeCycle.bindClass("producer", Commands.ProduceInteger.class); lifeCycle.bindGroovy("consumer", consumer); Commands.list.clear(); Throwable t = assertError("producer | consumer", ErrorKind.EVALUATION); ScriptException ex = assertInstance(ScriptException.class, t); assertEquals("foo", ex.getMessage()); }
Object dispatch(String methodName, Object[] arguments) { PipeCommandProxy pipe = resolvePipe(methodName, arguments, false); // try { pipe.fire(); return null; } catch (ScriptException e) { Throwable cause = e.getCause(); if (cause != null) { throw new InvokerInvocationException(cause); } else { throw e; } } finally { Safe.close(pipe); } }
break; } else { throw new ScriptException("Language " + name + " does not provide a repl"); throw new ScriptException("Language " + name + " not active"); context.provide("Using repl " + name); } else { throw new ScriptException("Repl " + name + " not found");
static ScriptException toScript(Throwable cause) { if (cause instanceof ScriptException) { return (ScriptException)cause; } if (cause instanceof groovy.util.ScriptException) { // Special handling for groovy.util.ScriptException // which may be thrown by scripts because it is imported by default // by groovy imports String msg = cause.getMessage(); ScriptException translated; if (msg != null) { translated = new ScriptException(msg); } else { translated = new ScriptException(); } translated.setStackTrace(cause.getStackTrace()); return translated; } else { return new ScriptException(cause); } }
public CommandInvoker<?, ?> resolve(String s) throws ScriptException, IOException { // A bit nasty : will improve that later CRaSHSession session = (CRaSHSession)getSession(); PipeLineParser parser= new PipeLineParser(s); PipeLineFactory factory = parser.parse(); try { return factory.create(session); } catch (NoSuchCommandException e) { throw new ScriptException(e); } }
public static ScriptException unwrap(groovy.util.ScriptException cause) { // Special handling for groovy.util.ScriptException // which may be thrown by scripts because it is imported by default // by groovy imports String msg = cause.getMessage(); ScriptException translated; if (msg != null) { translated = new ScriptException(msg); } else { translated = new ScriptException(); } translated.setStackTrace(cause.getStackTrace()); return translated; }
break; } else { throw new ScriptException("Language " + name + " does not provide a repl"); throw new ScriptException("Language " + name + " not active"); context.provide("Using repl " + name); } else { throw new ScriptException("Repl " + name + " not found");
public static ScriptException unwrap(groovy.util.ScriptException cause) { // Special handling for groovy.util.ScriptException // which may be thrown by scripts because it is imported by default // by groovy imports String msg = cause.getMessage(); ScriptException translated; if (msg != null) { translated = new ScriptException(msg); } else { translated = new ScriptException(); } translated.setStackTrace(cause.getStackTrace()); return translated; }
break; } else { throw new ScriptException("Language " + name + " does not provide a repl"); throw new ScriptException("Language " + name + " not active"); context.provide("Using repl " + name); } else { throw new ScriptException("Repl " + name + " not found");