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

error-custom-class

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-custom-class - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

1

build/src/main.d.ts

@@ -79,2 +79,3 @@ /**

onCreate?: OnCreate<ErrorNameArg, ErrorParamsArg>,
ParentClass?: Function,
): typeof CustomError<ErrorNameArg, ErrorParamsArg>

8

build/src/main.js

@@ -13,4 +13,8 @@ import{setErrorName}from"./name.js";

export default function errorCustomClass(name,onCreate=defaultOnCreate){
const CustomErrorClass=class extends Error{
export default function errorCustomClass(
name,
onCreate=defaultOnCreate,
ParentClass=Error)
{
const CustomErrorClass=class extends ParentClass{
constructor(message,params){

@@ -17,0 +21,0 @@ super(message,getErrorParams(params));

{
"name": "error-custom-class",
"version": "4.0.0",
"version": "4.1.0",
"type": "module",

@@ -49,3 +49,3 @@ "exports": "./build/src/main.js",

"devDependencies": {
"@ehmicky/dev-tasks": "^1.0.85",
"@ehmicky/dev-tasks": "^1.0.86",
"error-cause": "^1.0.4",

@@ -52,0 +52,0 @@ "error-cause-polyfill": "^1.1.0",

@@ -19,3 +19,4 @@ [![Codecov](https://img.shields.io/codecov/c/github/ehmicky/error-custom-class.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/error-custom-class)

[older Node.js and browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#browser_compatibility)
- Optional [custom initialization logic](#custom-initialization-logic)
- Optional [parent class](#parent-class) or
[custom initialization logic](#custom-initialization-logic)

@@ -58,2 +59,14 @@ # Examples

## Parent class
<!-- eslint-disable promise/prefer-await-to-callbacks -->
```js
const ParentError = errorCustomClass('ParentError')
const ChildError = errorCustomClass('ChildError', onCreate, ParentError)
const childError = new ChildError('message')
console.log(childError instanceof ChildError) // true
console.log(childError instanceof ParentError) // true
```
## Custom initialization logic

@@ -84,6 +97,7 @@

## errorCustomClass(errorName, onCreate?)
## errorCustomClass(errorName, onCreate?, ParentClass?)
`errorName` `string`\
`onCreate` `(error, params) => void`\
`ParentClass` `typeof Error`\
_Return value_: `CustomError`

@@ -149,2 +163,8 @@

error with its `cause`
- [`set-error-class`](https://github.com/ehmicky/set-error-class): Properly
update an error's class
- [`set-error-message`](https://github.com/ehmicky/set-error-message): Properly
update an error's message
- [`set-error-props`](https://github.com/ehmicky/set-error-props): Properly
update an error's properties
- [`error-cause-polyfill`](https://github.com/ehmicky/error-cause-polyfill):

@@ -151,0 +171,0 @@ Polyfill `error.cause`

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