
Research
GemStuffer Campaign Abuses RubyGems as Exfiltration Channel Targeting UK Local Government
GemStuffer abuses RubyGems as an exfiltration channel, packaging scraped UK council portal data into junk gems published from new accounts.
A json-serializable, incredibly ergonomic way of declaring and working with errors in your TypeScript applications.
A json-serializable, incredibly ergonomic way of defining and working with errors in your TypeScript applications.
import * as errf from ".";
// Define your errors
export type Error<K extends keyof typeof error> = errf.InferError<typeof error, K>;
const error = errf.create({
ApiError: {
code: "API_001",
message: (args: { url: string }) => `Error fetching ${args.url}`,
},
EmailError: {
code: "EMAIL_001",
message: (args: { email: string }) => `Error sending email to ${args.email}`,
},
});
// Write safe code
import type { Result } from "neverthrow";
import type { Error, error } from "./errors";
function safeFn(): Result<string, Error<"ApiError"> | Error<"EmailError">> {
// ...
}
const result = safeFn().match(
(v) => console.log(v),
(e) => {
errf.match(e, {
ApiError: (e) => console.log(`We couldn't service your request to ${e.config.url}`),
EmailError: () => console.error("We encountered an unexpected error"),
});
}
);
With the addition of libraries like neverthrow the JS community has started to realize the power of "never throwing" and instead returning results. This library is a great way to compliment that pattern.
Install errf:
npm i errf
Define your errors:
import * as errf from "errf";
const error = errf.create({
ApiError: {
code: "API_001",
message: (args: { url: string }) => `Error fetching ${args.url}`,
},
EmailError: {
code: "EMAIL_001",
message: (args: { email: string }) => `Error sending email to ${args.email}`,
},
});
Create errors by calling them as functions:
import { ResultAsync } from "nevereverthrow";
import { error } from "./errors";
const url = "https://api.example.com/data";
const result = ResultAsync.fromPromise(
() => fetch(url),
(e) => error.ApiError({ url }, e) // optionally add the cause
);
Errors defined with the userMessage property considered user facing errors. These are errors that are allowed to be shown to the user.
[!IMPORTANT] Internal errors should never be shown to the user.
Often times error handling can be verbose and it is expected for you to create utility functions for handling your user facing errors.
We can import the UserFacingError type from errf to ensure that we are only passing user facing errors to the function.
For functions expecting only internal errors you can use the
InternalErrortype.
import { UserFacingError } from "errf";
function showErrorToast(error: UserFacingError) {
// ...
}
You will often find yourself wanting to map an internal error to better user facing message. This can be done with the mapToUserFacingError function.
This can also be useful for localizing your error messages!
import * as errf from "errf";
// ...
const userFacingError = result.mapError((e) => errf.mapToUserFacingError(e, {
ApiError: (e) => `There was an error serving your request from ${e.config.url}`,
}));
Here are a few types you may want to implement to make using errf easier:
import * as errf from "errf";
// allows you to get the type of an error by name i.e. Error<"ApiError">
export type Error<K extends keyof typeof error> = errf.InferError<typeof error, K>;
// A union of all defined errors
export type AnyError = errf.InferAnyError<typeof error>;
// A union of all defined error codes
export type ErrorCodes = errf.InferErrorCodes<typeof error>;
const error = errf.create({
ApiError: {
code: "API_001",
message: (args: { url: string }) => `Error fetching ${args.url}`,
},
EmailError: {
code: "EMAIL_001",
message: (args: { email: string }) => `Error sending email to ${args.email}`,
},
});
FAQs
A json-serializable, incredibly ergonomic way of declaring and working with errors in your TypeScript applications.
We found that errf 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.

Research
GemStuffer abuses RubyGems as an exfiltration channel, packaging scraped UK council portal data into junk gems published from new accounts.

Company News
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.

Research
Socket detected 84 compromised TanStack npm package artifacts modified with suspected CI credential-stealing malware.