🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@altizure/errorcode

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@altizure/errorcode - npm Package Compare versions

Comparing version
2.0.0
to
2.0.1
+17
-19
index.js

@@ -21,19 +21,19 @@ const en = require('./i18n/en/index.json')

const { lang = 'en', descArgs = [], solArgs = [], code = [] } = props
const { lang = 'en', desc = [], sol = [], code = "" } = props
this.lang = lang
this.descArgs = descArgs
this.solArgs = solArgs
this.code = code
this.desc = desc
this.sol = sol
this.v2 = this.validate()
this.desc = expo[this.lang][this.code]['Description']
this.sol = expo[this.lang][this.code]['Solution']
this.code = expo[this.lang][this.code]['ErrorNumber']
const valid = this.validate()
this.codeStr = valid ? expo[this.lang][this.code]['ErrorNumber'] : this.code
this.descStr = valid ? expo[this.lang][this.code]['Description'] : this.code
this.solStr = valid ? expo[this.lang][this.code]['Solution'] : this.code
}
_getDesc () {
if (this.v2) {
return util.format(this.desc, ...this.descArgs)
if (this.desc.length > 0) {
return util.format(this.descStr, ...this.desc)
} else {
return this.desc
return this.descStr
}

@@ -43,6 +43,6 @@ }

_getSol () {
if (this.v2) {
return util.format(this.sol, ...this.solArgs)
if (this.sol.length > 0) {
return util.format(this.solStr, ...this.sol)
} else {
return this.sol
return this.solStr
}

@@ -52,3 +52,3 @@ }

_getCode () {
return this.code
return this.codeStr
}

@@ -58,9 +58,7 @@

if (!['en', 'zh-cn', 'zh-tw'].includes(this.lang)) {
throw new Error(`unsupported lang ${this.lang}`)
console.error(`unsupported lang ${this.lang}`)
return false
}
if (!expo[this.lang][this.code]) {
throw new Error(`no such error code ${this.code} in ${this.lang}`)
}
if (this.descArgs.length === 0 && this.solArgs.length === 0) {
console.warn(`no descArgs nor solArgs defined. v1 mode for ${this.code}`)
console.error(`no such error code ${this.code} in ${this.lang}`)
return false

@@ -67,0 +65,0 @@ }

{
"name": "@altizure/errorcode",
"version": "2.0.0",
"version": "2.0.1",
"description": "i18n of error code",

@@ -5,0 +5,0 @@ "main": "index.js",