public void reportNativeException(Exception e, IokeObject message, IokeObject context) throws ControlFlow { final IokeObject condition = IokeObject.as( IokeObject.getCellChain( this.condition, message, context, "Error", "NativeException"), context) .mimic(message, context); condition.setCell("message", message); condition.setCell("context", context); condition.setCell("receiver", context); condition.setCell("rootException", e); condition.setCell("exceptionType", newText(e.getClass().getName())); if (e.getMessage() != null) { condition.setCell("exceptionMessage", newText(e.getMessage())); } else { condition.setCell("exceptionMessage", nil); } List<Object> ob = new ArrayList<Object>(); for (StackTraceElement ste : e.getStackTrace()) { ob.add(newText(ste.toString())); } condition.setCell("exceptionStackTrace", newList(ob)); this.errorCondition(condition); }
@Override public Object activateWithData( final IokeObject self, IokeObject context, IokeObject message, Object on, Map<String, Object> data) throws ControlFlow { if (code == null) { IokeObject condition = IokeObject.as( IokeObject.getCellChain( context.runtime.condition, message, context, "Error", "Invocation", "NotActivatable"), context) .mimic(message, context); condition.setCell("message", message); condition.setCell("context", context); condition.setCell("receiver", on); condition.setCell("method", self); condition.setCell( "report", context.runtime.newText( "You tried to activate a method without any code - did you by any chance activate the DefaultMacro kind by referring to it without wrapping it inside a call to cell?")); context.runtime.errorCondition(condition); return null; } IokeObject c = context.runtime.locals.mimic(message, context); c.setCell("self", on); c.setCell("@", on); c.registerMethod( c.runtime.newJavaMethod( "will return the currently executing macro receiver", new JavaMethod.WithNoArguments("@@") { @Override public Object activate( IokeObject method, IokeObject context, IokeObject message, Object on) throws ControlFlow { getArguments() .getEvaluatedArguments( context, message, on, new ArrayList<Object>(), new HashMap<String, Object>()); return self; } })); c.setCell("currentMessage", message); c.setCell("surroundingContext", context); c.setCell("call", context.runtime.newCallFrom(c, message, context, IokeObject.as(on, context))); for (Map.Entry<String, Object> d : data.entrySet()) { String s = d.getKey(); c.setCell(s.substring(0, s.length() - 1), d.getValue()); } try { return ((Message) IokeObject.data(code)).evaluateCompleteWith(code, c, on); } catch (ControlFlow.Return e) { if (e.context == c) { return e.getValue(); } else { throw e; } } }