Huge News!Announcing our $40M Series B led by Abstract Ventures.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.

  • 4.0.11
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
483K
decreased by-42.83%
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

FAQs

Package last updated on 09 Dec 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc