Currently, some of my exceptions translate to this.
throw {
RE_EXN_ID: "Failure",
_1: message,
Error: new Error()
};
But I believe Rescript should create a class and then throw that. Furthermore, the resulting error prints an error along with the stack trace in Firefox instead of showing a stack trace stopping.
Rescript has it’s own exception system that you use when doing exception Foo and raise(Foo). These are meant to be caught within your rescript codebase and pattern matched on in the catch case, and it uses the RE_EXN_ID to make that happen
If you’re throwing an error that you don’t expect to handle, or are throwing errors for JS consumers, in Rescript 11 you can use Error.make and Error.raise from rescript/core
Error.make("Foo!")->Error.raise // throw new Error("Foo!")
I agree it is a sticking point. Specially as more and more things are fixed and better integrated with JS. I also agree that in future versions it would be great if exceptions got turned to first class JS exceptions and they avoided that idiosyncrasy.