🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

set-error-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

set-error-class - npm Package Compare versions

Comparing version
1.4.0
to
1.5.0
+1
-0
build/src/args.js
export const normalizeArgs=function(

@@ -3,0 +4,0 @@ error,

type NormalizeError<ErrorArg> = ErrorArg extends Error ? ErrorArg : Error
/**
* Sets the `error`'s
* [prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf),
* [`name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
* and
* [`constructor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor).
*
* @example
* ```js
* const typeError = new TypeError('test')
* console.log(typeError instanceof TypeError) // true
* console.log(typeError.name) // 'TypeError'
* console.log(typeError.constructor) // TypeError
* console.log(typeError.stack) // TypeError: test ...
*
* const rangeError = setErrorClass(typeError, RangeError)
* console.log(rangeError === typeError) // true
* console.log(rangeError instanceof RangeError) // true
* console.log(rangeError.name) // 'RangeError'
* console.log(rangeError.constructor) // RangeError
* console.log(rangeError.stack) // RangeError: test ...
* ```

@@ -12,3 +29,2 @@ */

ErrorClass: Function,
currentName?: string,
): NormalizeError<ErrorArg>
+2
-2
{
"name": "set-error-class",
"version": "1.4.0",
"version": "1.5.0",
"type": "module",

@@ -37,3 +37,3 @@ "exports": {

"@ehmicky/dev-tasks": "^1.0.102",
"test-each": "^5.5.0"
"test-each": "^5.6.0"
},

@@ -40,0 +40,0 @@ "engines": {

@@ -6,3 +6,3 @@ [![Node](https://img.shields.io/badge/-Node.js-808080?logo=node.js&colorA=404040&logoColor=66cc33)](https://www.npmjs.com/package/set-error-class)

[![Minified size](https://img.shields.io/bundlephobia/minzip/set-error-class?label&colorA=404040&colorB=808080&logo=webpack)](https://bundlephobia.com/package/set-error-class)
[![Twitter](https://img.shields.io/badge/-Twitter-808080.svg?logo=twitter&colorA=404040)](https://twitter.com/intent/follow?screen_name=ehmicky)
[![Mastodon](https://img.shields.io/badge/-Mastodon-808080.svg?logo=mastodon&colorA=404040&logoColor=9590F9)](https://fosstodon.org/@ehmicky)
[![Medium](https://img.shields.io/badge/-Medium-808080.svg?logo=medium&colorA=404040)](https://medium.com/@ehmicky)

@@ -15,3 +15,3 @@

- Sets an error's
[prototype, name and constructor](#seterrorclasserror-errorclass-currentname)
[prototype, name and constructor](#seterrorclasserror-errorclass)
- Update the [error's `stack`](#errorstack) with its new `name`

@@ -53,7 +53,6 @@ - Handles [invalid errors](#invalid-errors)

## setErrorClass(error, ErrorClass, currentName?)
## setErrorClass(error, ErrorClass)
`error` `Error | unknown`\
`ErrorClass` `typeof Error`\
`currentName` `string?`\
_Return value_: `Error`

@@ -80,4 +79,3 @@

[`error.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message).
If `error.stack` contains `currentName` (which defaults to the current
`error.name`), it is replaced with the new `error.name`.
It is updated accordingly.

@@ -108,2 +106,4 @@ ## Error constructors

update an error's properties
- [`set-error-stack`](https://github.com/ehmicky/set-error-stack): Properly
update an error's stack
- [`merge-error-cause`](https://github.com/ehmicky/merge-error-cause): Merge an

@@ -142,4 +142,4 @@ error with its `cause`

<!--
<table><tr><td align="center"><a href="https://twitter.com/ehmicky"><img src="https://avatars2.githubusercontent.com/u/8136211?v=4" width="100px;" alt="ehmicky"/><br /><sub><b>ehmicky</b></sub></a><br /><a href="https://github.com/ehmicky/set-error-class/commits?author=ehmicky" title="Code">💻</a> <a href="#design-ehmicky" title="Design">🎨</a> <a href="#ideas-ehmicky" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ehmicky/set-error-class/commits?author=ehmicky" title="Documentation">📖</a></td></tr></table>
<table><tr><td align="center"><a href="https://fosstodon.org/@ehmicky"><img src="https://avatars2.githubusercontent.com/u/8136211?v=4" width="100px;" alt="ehmicky"/><br /><sub><b>ehmicky</b></sub></a><br /><a href="https://github.com/ehmicky/set-error-class/commits?author=ehmicky" title="Code">💻</a> <a href="#design-ehmicky" title="Design">🎨</a> <a href="#ideas-ehmicky" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ehmicky/set-error-class/commits?author=ehmicky" title="Documentation">📖</a></td></tr></table>
-->
<!-- ALL-CONTRIBUTORS-LIST:END -->