npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bento/error

v0.1.1

Published

Custom error class for Bento

Downloads

256

Readme

Error

The @bento/error package creates custom Error objects that can be thrown as part of the framework. These custom error objects are designed to create a better DX for developers in a production environment.

Every created error will automatically include the following as part of the message:

  • Unobfuscated name of the component that threw the error.
  • Unobfuscated name of the function that threw the error.
  • Link to the documentation that is dedicated to the error.
  • Reference to our support channel.

Throwing or logging the error created above would result in the following output:

BentoError: @bento/package-name(method-name): The given name is already registered, please provide a different unique name

For more information visit: https://example.com/docs/errors/#AFBF4A

Need more help? Join our support channel #bento-support.
    at TestContext.<anonymous> (<path>/<file>:420:69)
    at Test.runInAsyncScope (node:async_hooks:211:14)
    at Test.run (node:internal/test_runner/test:931:25)
    at Test.start (node:internal/test_runner/test:829:17)
    at node:internal/test_runner/test:1308:71
    at node:internal/per_context/primordials:483:82
    at new Promise (<anonymous>)
    at new SafePromise (node:internal/per_context/primordials:451:29)
    at node:internal/per_context/primordials:483:9
    at Array.map (<anonymous>)

Installation

npm install --save @bento/error

BentoError

The package exposes the BentoError Error class that can be used to create custom errors.

import { BentoError } from '@bento/error';

throw new BentoError({
  name: 'package-name',
  method: 'method-name',
  message: 'The given name is already registered, please provide a different unique name'
});

The following keys are required:

Changing the name, method, or message properties will result in a different hash. This hash is the reference to the error on the documentation page. If you change any of these properties, you must also update the documentation page.

<h2 id="place-the-generated-hash-here"></h2>

<!--
 As mentioned above, it's possible that a different hash was previously generated.
 You still want to keep the hash on the documentation page to ensure that older
  versions of the framework can still be accessed in the right section.
-->
<a name="place-the-previous-hash-here"></a>

The following keys are optional:

Any other key added to the object will be introduced as a property on the error object. This can be useful for debugging purposes when you want to provide additional information to the developer.

Example

import { BentoError, type BentoErrorArgs } from '@bento/error';
/* v8 ignore next */
import React, { useCallback, type JSX } from 'react';

/**
 * Throws component renders a button that logs a BentoError to the console when clicked.
 *
 * @param {Object} props - The properties passed to the component.
 * @returns {JSX.Element} A button element that triggers the createError function on click.
 *
 * @example
 * <Throws message={value} method="example" name="error" />
 *
 * @component
 */
export function Throws(props: BentoErrorArgs): JSX.Element {
  //
  // We're using useCallback here to prevent the function from being recreated
  // on every render as it's passed as a prop to the button component.
  //
  const createError = useCallback(
    function createError() {
      console.error(new BentoError(props));
    },
    [props]
  );

  return (
    <button name="error" onClick={createError}>
      Log bento error in console
    </button>
  );
}