
Research
/Security News
Fake imToken Chrome Extension Steals Seed Phrases via Phishing Redirects
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.
@studio/fail
Advanced tools
🚨 Fail with an Error object and a conventional code property.
const { failure, INVALID } = require('@studio/fail');
function read(filename, callback) {
if (!filename) {
// Easily fail with a conventional error:
throw failure('Missing filename', INVALID);
}
// ...
}
const fs = require('fs');
const { fail, then, INVALID } = require('@studio/fail');
function read(filename, callback) {
if (!filename) {
// Easily fail with a conventional error:
fail(callback, 'Missing filename', INVALID);
return;
}
// Wrap callbacks with and error handling, guarding from multiple invocations:
fs.readFile(
filename,
'utf8',
then(callback, (content) => {
// Non-undefined return value is passed to callback:
return content.trim();
})
);
}
Errors should always have a code property with an uppercase error code. To
simplify error handling, use the provided fail utility function and code
constants.
Error codes follow these conventions:
E_. This is the
asynchronous equivalent to throw. The provided message is not supposed to
be shown to the user.message may be shown to the user.code property is provided, it defaults to E_FAILED.The provided error codes can be handled generically. You may define additional error codes as needed.
❯ npm i @studio/fail
failure(message[, cause][, code[, properties]]): Create an Error
with the given message and cause and code and properties. If no code
is provided it defaults to E_FAILED. The cause must be an error object.fail(callback, message[, cause][, code[, properties]]): Creates a failure
and invoked the given callback with it.isFatal(error): Whether the given error has a code property the starts
with E_ or has no code property.then(callback, next): Create a callback function that invokes
callback(err) if an error occurred and next(result) on success. Throws if
the function is invoked more than once with error code E_FAILED and err
as the cause. If next returns a non-undefined value, the callback is
invoked with that result.E_FAILED: Fatal error.INVALID: Invalid or missing argument or parameter.FORBIDDEN: User is not allowed to access.NOT_FOUND: Resource does not exist.Throwing errors:
const { failure, INVALID } = require('@studio/fail');
// Fail with a message:
throw failure('Oups!');
// The previous is the same as this:
throw failure('Oups!', E_FAILED);
// Fail with `code` INVALID:
throw failure('Oups!', INVALID);
// Fail with a `cause`:
const cause = new Error();
throw failure('Oups!', cause);
// Fail with a `cause` and `code` INVALID:
throw failure('Oups!', cause, INVALID);
// Fail with `properties` and `code` INVALID:
throw failure('Oups!', INVALID, { some: 42 });
Invoking callbacks with errors:
const { fail, FORBIDDEN } = require('@studio/fail');
fail(callback, 'Oups!', FORBIDDEN);
code and cause aware.MIT
Made with ❤️ on 🌍
FAQs
Fail with an Error object and a conventional code property
The npm package @studio/fail receives a total of 47 weekly downloads. As such, @studio/fail popularity was classified as not popular.
We found that @studio/fail demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
/Security News
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.

Security News
Latio’s 2026 report recognizes Socket as a Supply Chain Innovator and highlights our work in 0-day malware detection, SCA, and auto-patching.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.