Skip to content

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

@jmagaram

Description

@jmagaram
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.

Activity

zth

zth commented on Mar 21, 2023

@zth
Collaborator

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zth@jmagaram

        Issue actions

          Flattening out the Error module, couple other comments on it · Issue #113 · rescript-lang/rescript-core