Open gilch opened 2 months ago
Unfortunately, right now, life is pretty busy. So, I can't work on it beyond maybe improving the message in the minibuffer from usrpointer to the error returned from parinfer. However, I agree that better error handling is needed. For reference there is a long-standing todo to improve error handling beyond just sending an error to the minibuffer.
Another thought I had was that rather than building a UI to display error messages, an integration with flymake and flycheck could be built. Then, parinfer-rust-mode would use standard error reporting methods. This has the plus side of probably being a lot easier because someone would only have to build a transformer from a parinfer-rust error message to a flymake or flycheck.
I relation to cleaning up the error messages, it seems that the rust library was surrounding the Error
type returned in the :error
field of the answer struct with a Box
. Removing this makes it possible to access the plist from lisp. From there, giving a better error message is like a 2 line change.
In parinfer-rust-mode parinfer-rust--execute
:
(if error-p
;; TODO handle errors
(message "Problem on line %s: %s"
(plist-get error-p :line_no)
(plist-get error-p :message))
...)
and in parinfer-rust-emacs get_answer
:
AnswerKey::Error => match unwrapped_answer.error.clone() {
Some(error) => Ok(error.into_lisp(env)?),
None => ().into_lisp(env),
},
I have created repos at Zander671/parinfer-rust-mode and Zander671/parinfer-rust-emacs and tested these on my own config. However, this is such a small change, I hesitate to make pull requests since it might be faster if someone with direct access just makes them directly.
Hey, @Zander671, I've added your changes to parinfer, which looks to have been the major problem. So, thanks for looking into this. 🙇
In a situation with an unbalanced
"
in a comment (#99, wontfix).The only feedback the Emacs user gets are some cryptic messages about
#<user-ptr...
. This is unfriendly behavior. The user needs to know what the problem is and how to fix it.I'd suggest highlighting the offending quote, if possible, displaying a message about the offending line number instead of about a pointer (in case it's not on the screen), and changing the normal dimmed closing brackets to red or something to indicate that Parinfer is not in its normal state such that it can handle said brackets for you.
As it is now, as far as the user can tell, parinfer-rust-mode has just mysteriously stopped working.