
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
When you have an error-ish but what you really want is an Error.
There are three main use cases for Errorish:
Error has a message, name, and stack properties.Error class to store an identifying label, a source error, and/or associated data.Exception is an Error extending class with additional label, error and data fields.ensure ensures any is an Error, otherwise creating one -it can optionally include a normalization step, enabled by default.normalize ensures an Error has a message, name, and stack properties -filling them if they're not defined.capture runs Error.captureStackTrace if running in V8 to clean up the error stack trace.ExceptionSee documentation for Exception.
Exception is an Error extending class that can store an identifying label, the source error that caused it and/or additional associated data. Exception also comes with several static and instance methods.
import { Exception } from 'errorish';
try {
try {
throw new Error('Source');
} catch (err) {
// throws with label
throw new Exception(['label', 'message'], err, { code: 401 });
}
} catch (err) {
// throws without label
throw new Exception(err.message, err, { code: 500 })
}
ensureEnsure will return its first argument if an instance of Error is passed as such, otherwise instantiating and returning an Exception.
import { ensure } from 'errorish';
ensure('foo'); // Error: foo
ensure(new Error('foo')); // Error: foo
ensure({ message: 'foo' }); // Error: foo
normalizeSee documentation for normalize.
Normalization fills an error's message, name, and stack property when empty. It's performed by default by ensure, but it can also be run independently.
import { normalize } from 'errorish';
normalize(new Error()); // Error: An error occurred
normalize(new Error(), { message: 'Foo bar' }); // Error: Foo bar
captureSee documentation for capture.
Captures the stack trace on Node and Chromium browsers.
import { capture } from 'errorish';
capture(new Error());
FAQs
When you have an error-ish but what you really want is an Error
The npm package errorish receives a total of 1,095 weekly downloads. As such, errorish popularity was classified as popular.
We found that errorish demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.