@litert/core
Advanced tools
Comparing version 1.0.6 to 1.0.7
# Changes Logs | ||
## v1.0.7 | ||
- Added `setCodeBase` method for `IErrorHub`. | ||
- Now the counter of auto-increase code number will be overwritten by a bigger specific code number | ||
while defining a new error. | ||
## v1.0.6 | ||
@@ -4,0 +10,0 @@ |
@@ -178,2 +178,8 @@ /** | ||
/** | ||
* Set the base of error code number while defining an error with an omitted code number. | ||
* | ||
* @param codeBase The new base of error code number. | ||
*/ | ||
setCodeBase(codeBase: number): this; | ||
/** | ||
* Get the error constructor by its name or code. | ||
@@ -180,0 +186,0 @@ * |
@@ -126,2 +126,6 @@ "use strict"; | ||
} | ||
setCodeBase(codeBase) { | ||
this._counter = codeBase; | ||
return this; | ||
} | ||
get module() { | ||
@@ -154,5 +158,11 @@ return this._module; | ||
} | ||
else { | ||
this._counter = code; | ||
if (this._errors[code]) { | ||
const TheError = DEFAULT_HUB.get("DUPLICATED_ERROR_CODE"); | ||
throw new TheError({ | ||
message: `The code ${JSON.stringify(code)} of new error already exists.` | ||
}); | ||
} | ||
if (code > this._counter) { | ||
this._counter = code + 1; | ||
} | ||
if (this._errors[name]) { | ||
@@ -174,8 +184,2 @@ const TheError = DEFAULT_HUB.get("DUPLICATED_ERROR_NAME"); | ||
} | ||
if (this._errors[code]) { | ||
const TheError = DEFAULT_HUB.get("DUPLICATED_ERROR_CODE"); | ||
throw new TheError({ | ||
message: `The code ${JSON.stringify(code)} of new error already exists.` | ||
}); | ||
} | ||
if (aliasCodes.length) { | ||
@@ -182,0 +186,0 @@ for (const alias of aliasCodes) { |
{ | ||
"name": "@litert/core", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "The core of LiteRT.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -351,2 +351,9 @@ /** | ||
/** | ||
* Set the base of error code number while defining an error with an omitted code number. | ||
* | ||
* @param codeBase The new base of error code number. | ||
*/ | ||
setCodeBase(codeBase: number): this; | ||
/** | ||
* Get the error constructor by its name or code. | ||
@@ -390,2 +397,9 @@ * | ||
public setCodeBase(codeBase: number): this { | ||
this._counter = codeBase; | ||
return this; | ||
} | ||
public constructor(moduleName: string) { | ||
@@ -464,7 +478,17 @@ | ||
} | ||
else { | ||
this._counter = code; | ||
if (this._errors[code]) { | ||
const TheError = DEFAULT_HUB.get("DUPLICATED_ERROR_CODE"); | ||
throw new TheError({ | ||
message: `The code ${JSON.stringify(code)} of new error already exists.` | ||
}); | ||
} | ||
if (code > this._counter) { | ||
this._counter = code + 1; | ||
} | ||
if (this._errors[name]) { | ||
@@ -494,11 +518,2 @@ | ||
if (this._errors[code]) { | ||
const TheError = DEFAULT_HUB.get("DUPLICATED_ERROR_CODE"); | ||
throw new TheError({ | ||
message: `The code ${JSON.stringify(code)} of new error already exists.` | ||
}); | ||
} | ||
if (aliasCodes.length) { | ||
@@ -505,0 +520,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121534
2567