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 2.0.1 to 2.0.2

19

index.js

@@ -0,1 +1,3 @@

const State = require('@darkwolf/state')
class CodeError extends Error {

@@ -12,2 +14,3 @@ constructor(...args) {

this.namespace = namespace
this.space = namespace
this.code = code

@@ -22,19 +25,9 @@ this.message = message

}
}
setData(data) {
this.data = data
return this
const {state, setState} = new State()
this.state = state
this.setState = setState
}
updateData(callback) {
return this.setData(callback(this.data))
}
deleteData() {
this.data = undefined
return this
}
}
module.exports = CodeError
{
"name": "@darkwolf/code-error",
"version": "2.0.1",
"version": "2.0.2",
"description": "Code Error Utility",

@@ -24,3 +24,6 @@ "main": "index.js",

},
"homepage": "https://github.com/darkwolf/code-error#readme"
"homepage": "https://github.com/darkwolf/code-error#readme",
"dependencies": {
"@darkwolf/state": "^1.0.0"
}
}

@@ -11,5 +11,3 @@ # Code Error Utility

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)
const SPACE_CODE_ERROR = new CodeError(namespace, code, message)

@@ -19,5 +17,14 @@ try {

} catch (e) {
switch (e.code) {
case code:
doSmth()
switch (e.space) {
case 'namespace': {
switch (e.code) {
case 'invalid-code': {
doSmth()
break
}
default: throw e
}
break
}
default: throw e
}

@@ -29,4 +36,2 @@ }

## Methods
### setData(data)
### updateData(data => newData)
### deleteData()
### setState(newState || callbac(state => newState))
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