ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Improve error handling

Open zmievsa opened this issue 3 years ago • 1 comments

There are a few moments in the code base with unhandled exceptions that could make it harder to the users to understand the errors. Examples:

  • experimental_syntax_encoding.py, line 52 -> transform source could be None. We could either raise a better error here or replace None with lambda s: s.
  • Same file, line 15 -> search_function can return None instead of an encoding. Even though it's incredibly unlikely, mypy/pylance won't like it and in the future we might encounter cases where utf-8 is not available. In that case, adding a single check in the beginning can help the users in that rare case. Additionally, less red text is good :)

I am not touching on examples because they obviously need a bit less error handling.

zmievsa avatar May 24 '22 15:05 zmievsa

I've actually been thinking of removing experimental_syntax_encoding.py after working on https://github.com/aroberge/ideas/blob/master/ideas/examples/experimental_syntax.py which I find more versatile. I don't believe that it suffers from the same kind of problems. However, I do need to document it.

aroberge avatar May 24 '22 15:05 aroberge