News for hackers. Stuff that matters.
Re:A better way to handle errors in JavaScript by musicq on Tuesday October 31, 2023 @07:29AM (#38083152)
The thing is not using try/catch, like the first case, sometimes you don't know if a function will throw or not. You can't tell from the function signature as well.

So this provides a way that told you the function you called might throw. It's more like an alert before a crash.

[res, err] is good, actually I used this style for a long time. `unwrapit` is a nicer way to let you write [res, err], like type hints and other utility methods.

There are no comments on this comment yet.