Recent submissions

Comment · 3 years ago
Thank you for the suggestion! I will add that.
Comment · 3 years ago
Comment · 3 years ago
try/catch has no problem, but the premise is that you know there will be errors been thrown. Say a function `divide`, you can barely tell that whether it will throw errors or not without looking into the source code.
Comment · 3 years ago
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.

Comment · 3 years ago
Comment · 3 years ago
Comment · 3 years ago
Actually rxjs is a `peerDependency` which means it will assume the user will have it installed already.
Comment · 3 years ago
Spent sometime to complete the document of my rust Result like library `unwrapit` for JS/TS.

Still think this might be a proper way to deal with errors in JS/TS

Comment · 3 years ago
reprint
Comment · 3 years ago
Use Rust Result types in TypeScript to handle errors easier in both sync/async functions.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton