New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

makeerror

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makeerror

A library to make errors.

  • 1.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25M
increased by3.78%
Maintainers
1
Weekly downloads
 
Created

What is makeerror?

The makeerror npm package provides a simple way to create custom error types in JavaScript. It allows developers to define new error types with specific properties and methods, enhancing error handling in applications by making it more structured and informative.

What are makeerror's main functionalities?

Creating custom error types

This feature allows developers to create new error types. The example shows how to define a custom error type named 'MyError' and create an instance of it with a specific message.

const makeError = require('makeerror');
const MyError = makeError('MyError');
const errorInstance = new MyError('Something went wrong!');
console.log(errorInstance.name); // 'MyError'
console.log(errorInstance.message); // 'Something went wrong!'

Custom error with additional properties

This feature demonstrates how to add additional properties to a custom error type. In the example, a 'statusCode' property is added to the 'MyError' type, which can be useful for HTTP error handling.

const makeError = require('makeerror');
const MyError = makeError('MyError', { statusCode: 404 });
const errorInstance = new MyError('Not found');
console.log(errorInstance.statusCode); // 404

Other packages similar to makeerror

FAQs

Package last updated on 23 Oct 2021

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