Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve failed evaluation detection, reporting #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

holyjak
Copy link
Member

@holyjak holyjak commented Sep 21, 2024

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!
]

@holyjak holyjak force-pushed the improve-error-handling-on-failed-eval branch 2 times, most recently from 1f4ba98 to 5c0f226 Compare September 22, 2024 10:46
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.
@holyjak holyjak force-pushed the improve-error-handling-on-failed-eval branch from 5c0f226 to 7253ec9 Compare September 22, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant