A Go Like try-catch System
bun i @niceeli/try-catch
import safe from "@niceeli/try-catch";
const [data, err, type] = await safe(fetch("https://example.com"));
// data is Response | null
if (err) {
console.error(`Error: ${err} (${type})`);
return;
}
// data is Response now, both you and the type system know 100% sure its not null
console.log(data.text());