Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@darkwolf/code-error

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkwolf/code-error - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

.gitattributes

31

index.js
class CodeError extends Error {
constructor(code, message, data) {
constructor(...args) {
super()
this.name = 'CodeError'
this.code = code
this.message = message
this.data = data
if (args.length <= 2) {
const [code, message] = args
this.code = code
this.message = message
} else {
const [namespace, code, message] = args
this.namespace = namespace
this.code = code
this.message = message
}
if (Error.captureStackTrace) {

@@ -15,4 +22,18 @@ Error.captureStackTrace(this, CodeError)

}
setData(data) {
this.data = data
return this
}
updateData(callback) {
return this.setData(callback(this.data))
}
deleteData() {
this.data = undefined
return this
}
}
module.exports = CodeError

8

package.json
{
"name": "@darkwolf/code-error",
"version": "1.0.2",
"description": "CodeError",
"version": "2.0.0",
"description": "Code Error Utility",
"main": "index.js",

@@ -15,3 +15,5 @@ "scripts": {

"code",
"error"
"error",
"utility",
"utils"
],

@@ -18,0 +20,0 @@ "author": "Pavel Wolf",

@@ -1,10 +0,14 @@

# Code Error
# Code Error Utility
## Install
```sh
npm i --save @darkwolf/code-error
```
## Use
## Usage
```javascript
const CodeError = require('@darkwolf/code-error')
const CODE_ERROR = new CodeError(code, message, data)
const CODE_ERROR = new CodeError(code, message)
const NAMESPACE_CODE_ERROR = new CodeError(namespace, code, message)
const DATA_CODE_ERROR = new CodeError(code, message).setData(data)
const DATA_NAMESPACE_CODE_ERROR = new CodeError(namespace, code, message).setData(data)

@@ -16,3 +20,2 @@ try {

case code:
const data = e.data
doSmth()

@@ -22,1 +25,7 @@ }

```
## Initialization
### new CodeError(namespace?, code, message)
## Methods
### setData(data)
### setUpdate(update => newUpdate)
### deleteData()
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