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

Add lastError function #3654

Draft
wants to merge 8 commits into
base: development
Choose a base branch
from

Conversation

d-torrance
Copy link
Member

This returns a sequence containing the location and message string for the last error (at least most of the time, e.g., not for syntax errors).

The eventual goal is to use this in the MPI package (see #2129) for handling errors gracefully, e.g., doing something like try x else lastError().

d-torrance and others added 8 commits February 9, 2025 15:17
Sets lastError, so use it for constructing all errors except control
transferring errors like return, continue, etc.
Also set position for suppressed errors
In particular, we previously constructed the error message when
returning with it (when stopIfError/returnIfError true).  Now we
always construct it (so it gets saved to lastError), but only return
with it in those cases.
Also remove a bunch of cruft in the file error-messages.m2
e(x,p1,h1)
f(x,p1,h1)
g(x,p1,h1)
assert((last try 1/0 else lastError()) == "division by zero")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning on replacing the manual tests above with automatic versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@pzinn
Copy link
Contributor

pzinn commented Feb 13, 2025

I did something similar on my dev branch. I'll compare the code.

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.

4 participants