
Security News
Google’s OSV Fix Just Added 500+ New Advisories — All Thanks to One Small Policy Change
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
@dschz/try-catch
Advanced tools
A tiny utility to wrap promises or async functions and return a
[error, data]
tuple — no moretry/catch
boilerplate.
Result<T, E>
npm install @dschz/try-catch
pnpm install @dschz/try-catch
yarn install @dschz/try-catch
bun install @dschz/try-catch
import { tryCatch } from "@dschz/try-catch";
const [err, data] = await tryCatch(fetch("/api/data"));
if (err) {
console.error("Something went wrong:", err);
} else {
console.log("Data:", data);
}
You can also pass a function that returns a promise:
const [err, user] = await tryCatch(() => fetchUserById(123));
type Success<T> = [error: null, data: T];
type Failure<E extends Error = Error> = [error: E, data: null];
type Result<T, E extends Error = Error> = Success<T> | Failure<E>;
The return value is a tuple:
[error, data]; // One will always be null
class MyError extends Error {
constructor(message: string) {
super(message);
this.name = "MyError";
}
}
const [err, data] = await tryCatch<MyType, MyError>(() => doSomething());
MIT © @dschz
FAQs
Simple try-catch utility function for JavaScript
The npm package @dschz/try-catch receives a total of 137 weekly downloads. As such, @dschz/try-catch popularity was classified as not popular.
We found that @dschz/try-catch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
Research
/Security News
175 malicious npm packages (26k+ downloads) used unpkg CDN to host redirect scripts for a credential-phishing campaign targeting 135+ organizations worldwide.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.