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.9 to 2.1.0

28

index.js

@@ -10,3 +10,3 @@ const validator = require('@darkwolf/validator')

if (validator.isObjectExact(params)) {
if (validator.isPlainObject(params)) {
const {

@@ -24,4 +24,4 @@ namespace,

.throw(() => new TypeError('"params.namespace" property must be a string'))
.isLength(2, 64)
.throw(() => new Error('"params.namespace" property must be between 2 and 64 characters long'))
.isLength(1, 64)
.throw(() => new Error('"params.namespace" property must be between 1 and 64 characters long'))
this.namespace = namespace

@@ -52,4 +52,4 @@ }

.throw(() => new TypeError('"params.message" property must be a string'))
.isLength(0, 2048)
.throw(() => new Error('"params.message" property must be between 0 and 2048 characters long'))
.isLength(1, 4096)
.throw(() => new Error('"params.message" property must be between 1 and 4096 characters long'))
this.message = message

@@ -60,3 +60,3 @@ }

new Validator(state)
.isObjectExact()
.isPlainObject()
.throw(() => new TypeError('"params.state" property must be an object'))

@@ -82,4 +82,4 @@ this.state = state

.throw(() => new TypeError('"message" argument must be a string'))
.isLength(0, 2048)
.throw(() => new Error('"message" argument must be between 0 and 2048 characters long'))
.isLength(1, 4096)
.throw(() => new Error('"message" argument must be between 1 and 4096 characters long'))
this.message = message

@@ -101,4 +101,4 @@ }

.throw(() => new TypeError('"namespace" argument must be a string'))
.isLength(2, 64)
.throw(() => new Error('"namespace" argument must be between 2 and 64 characters long'))
.isLength(1, 64)
.throw(() => new Error('"namespace" argument must be between 1 and 64 characters long'))
this.namespace = namespace

@@ -138,4 +138,4 @@ return this

.throw(() => new TypeError('"message" argument must be a string'))
.isLength(0, 2048)
.throw(() => new Error('"message" argument must be between 0 and 2048 characters long'))
.isLength(1, 4096)
.throw(() => new Error('"message" argument must be between 1 and 4096 characters long'))
return this

@@ -148,3 +148,3 @@ }

.throw(() => new Error('"newState" argument is required'))
if (validator.isObjectExact(newState)) {
if (validator.isPlainObject(newState)) {
this.state = newState

@@ -154,3 +154,3 @@ } else if (validator.isFunction(newState)) {

new Validator(state)
.isObjectExact()
.isPlainObject()
.throw(() => new TypeError('"newState" argument must return an object'))

@@ -157,0 +157,0 @@ this.state = state

{
"name": "@darkwolf/code-error",
"version": "2.0.9",
"version": "2.1.0",
"description": "Code Error Utility",

@@ -26,4 +26,4 @@ "main": "index.js",

"dependencies": {
"@darkwolf/validator": "^2.0.8"
"@darkwolf/validator": "^2.1.6"
}
}

@@ -31,18 +31,18 @@ # Code Error Utility

class CustomNamespaceError extends CodeError {
class DarkwolfError extends CodeError {
constructor(...args) {
super(...args)
this.namespace = 'custom-namespace'
this.namespace = 'darkwolf'
}
}
const INVALID_VALUE = new CustomNamespaceError('invalid-value', 'Invalid value')
const INVALID_DARKWOLF_ID = new DarkwolfError('invalid-darkwolf-id', 'Invalid Darkwolf ID')
try {
throw INVALID_VALUE
throw INVALID_DARKWOLF_ID
} catch (e) {
switch (e.namespace) {
case 'custom-namespace': {
case 'darkwolf': {
switch (e.code) {
case 'invalid-value': {
case 'invalid-darkwolf-id': {
doSmth()

@@ -49,0 +49,0 @@ break

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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