Socket
Socket
Sign inDemoInstall

@huolala-tech/custom-error

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@huolala-tech/custom-error

Used to fix the odd behaviors of native Error object inheritance code compiled to ES5.


Version published
Weekly downloads
11
decreased by-77.08%
Maintainers
1
Weekly downloads
 
Created
Source

CustomError

Used to fix the odd behaviors of native Error object inheritance code compiled to ES5.

Why?

If your code is compiled to ES5 target, you may encounter an unexpected behavior.

class MyError extends Error {
  // blah blah blah
}

const error = new MyError();

console.log(error instanceof Error); // true
console.log(error instanceof MyError); // false <!-- should be true

see https://babeljs.io/docs/en/caveats/#classes

Use the CustomError

import { CustomError } from '@huolala-tech/custom-error';

class MyError extends CustomError {
  // blah blah blah
}

const error = new MyError();

console.log(error instanceof Error); // true
console.log(error instanceof MyError); // true
console.log(error instanceof CustomError); // true

FAQs

Package last updated on 07 Feb 2023

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