rune icon indicating copy to clipboard operation
rune copied to clipboard

How to represent type errors when `_or_` is involved?

Open shaleh opened this issue 1 year ago • 1 comments

I see there is a TypeError defined in core/error.rs. However, the Emacs C code often has something like:

return wrong_type_argument (Qchar_or_string_p, obj);

Does that mean the Type enum needs to learn about "CharOrString" and all the other permutations of this? I bumped into this while exploring what it would take to implement downcase.

shaleh avatar Oct 12 '23 20:10 shaleh

The Error handling needs to be reworked to align with Emacs. Emacs' errors are conses that have an error symbol followed by additional information. The errors in Rune are just anyhow::Error's that are basically a catch all for any type. Part of that is I didn't really understand how errors were structured when I started this.

(condition-case x
    (downcase '(1))
  (wrong-type-argument (setq my-error x)))
(consp my-error)

Basically we need a new error type that is more structured and follows the convention of Emacs. In the meantime you are correct, we can add a CharOrString type to the Type enum.

CeleritasCelery avatar Oct 12 '23 23:10 CeleritasCelery