Issue: When we ask Wolfram to do something impossible, it typically returns the input form or $Failed, so it is hard to see what was wrong. However, when evaluated in a notebook, it does print an explanation. This is however ignored by the recommended .waitForAnswer.
Fix: Follow the docs and add a packet listener, which captures the messages we care about in these cases (text, message) between we start eval and read the result. To make this easier, move the impl. of evaluation into a new protocol method evaluate! + add extracting captured messages from the listener + throw an error if the result seems to indicate a problem.
Bonus: Upgrade Clojure to stable.
Demo
What does this look like?
(wl/eval "Subtract[1]")
Execution error (ExceptionInfo) at wolframite.impl.jlink_proto_impl.JLinkImpl/evaluate_BANG_ (jlink_proto_impl.clj:151).
Evaluation seems to have failed. Result: Subtract[1] Details: Subtract::argr: Subtract called with 1 argument; 2 arguments are expected.
(wl/eval "Get[\"/no-such-file\"]")
Execution error (ExceptionInfo) at wolframite.impl.jlink_proto_impl.JLinkImpl/evaluate_BANG_ (jlink_proto_impl.clj:151).
Evaluation seems to have failed. Result: $Failed Details: Get::noopen: Cannot open /no-such-file.
(wl/eval "Print[\"hello!\"]") ; => nil
[nREPL-session-101a2c04-a45a-4559-9cb5-319d8574a740] INFO wolframite.impl.jlink-proto-impl - Messages retrieved during evaluation: [hello!
]
Issue: When we ask Wolfram to do something impossible, it typically returns the input form or $Failed, so it is hard to see what was wrong. However, when evaluated in a notebook, it does print an explanation. This is however ignored by the recommended
.waitForAnswer
.Fix: Follow the docs and add a packet listener, which captures the messages we care about in these cases (text, message) between we start eval and read the result. To make this easier, move the impl. of evaluation into a new protocol method
evaluate!
+ add extracting captured messages from the listener + throw an error if the result seems to indicate a problem.Bonus: Upgrade Clojure to stable.
Demo
What does this look like?