-
Notifications
You must be signed in to change notification settings - Fork 239
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
base: development
Are you sure you want to change the base?
Add lastError function #3654
Conversation
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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
I did something similar on my dev branch. I'll compare the code. |
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()
.