Standardize error structures. #103
Labels
feature-request
Any request for a new feature of the language. Includes both syntax and library features.
stdlib
Any issue relating to the standard library (Myst code) of Myst.
One of the "marketed features" of Myst is that any value can be raised as an exception. This is great for user-land code, letting
raise
act like a more powerfulbreak
, but can be a nightmare for consistency and extendability in libraries and frameworks.I see a few aspects to this:
NoClauseError
,MatchError
,ParseError
, etc.FileNotFound
,DivideByZero
, etc. (these are examples. Actual errors will probably differ).RuntimeError
s from the Interpreter #98 for a start).Additionally, an important part of rescuing errors is knowing where the error came from. With normal values as exceptions, this won't always be possible (e.g., integers don't have a callstack attached to them). For this, I have two ideas:
Add an optional second parameter for
rescue
that captures cause information separately. This would be similar to the result of thecaller
method that Ruby provides. This feels like it would need a distinguishing syntax to avoid confusion with passing multiple values:Assume a standard method name for getting callstack info in a rescue. This is implicit and I don't particularly like it, but avoids the confusion from above:
I'm not super excited by either of those, but I'm leaning towards the first, at least as a temporary implementation.
The text was updated successfully, but these errors were encountered: