Skip to content
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

Flattening out the Error module, couple other comments on it #113

Open
jmagaram opened this issue Mar 19, 2023 · 1 comment
Open

Flattening out the Error module, couple other comments on it #113

jmagaram opened this issue Mar 19, 2023 · 1 comment

Comments

@jmagaram
Copy link
Contributor

I've been looking at the Error module. It is hard to raise exceptions because each of the different types are exposed in sub-modules like Error.SyntaxError that contain a single function - raise. At a glance you can't tell what the different types of exceptions are and must navigate into the sub-module to do it. The Intellisense menu looks like this...

image

I much prefer the Js.Exn way of doing it.

image

I notice an Error.make function. Is there anything you can do with it before raising it? Because if not, just remove make and go straight to throwing. If we want the ability to add custom properties first, I'm not sure how you'd do that. Consider adding some of the get and set functions from Object or convert to object.

@zth
Copy link
Collaborator

zth commented Mar 21, 2023

Adding those shortcuts (raiseEvalError, raiseRangeError etc) is fine by me, if that helps with the ergonomics.

You can create an Error in JS without throwing it directly, and presumably that's what Error.make emulates. So we shouldn't remove that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants