🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

ono

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ono

Throw better errors.

7.1.3
latest
Source
npm
Version published
Weekly downloads
1M
12.72%
Maintainers
1
Weekly downloads
 
Created

What is ono?

The 'ono' npm package is a utility for creating and managing errors in JavaScript. It allows you to create custom error messages, wrap existing errors, and add additional context to errors. This can be particularly useful for debugging and logging purposes.

What are ono's main functionalities?

Creating Custom Errors

This feature allows you to create custom error messages. The 'ono' function can be used to generate a new error with a specific message.

const ono = require('ono');

const error = ono('Something went wrong!');
console.error(error);

Wrapping Existing Errors

This feature allows you to wrap existing errors with additional context. This can be useful for adding more information to errors that are caught during execution.

const ono = require('ono');

try {
  JSON.parse('invalid JSON');
} catch (err) {
  const wrappedError = ono(err, 'Failed to parse JSON');
  console.error(wrappedError);
}

Adding Context to Errors

This feature allows you to add additional context to errors, such as custom properties. In this example, a status code is added to the error object.

const ono = require('ono');

const error = ono({ status: 404 }, 'Resource not found');
console.error(error);
console.error(error.status);

Other packages similar to ono

Keywords

throw

FAQs

Package last updated on 15 Jul 2020

Did you know?

Socket

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.

Install

Related posts