feat: 错误代码不存在时报错

This commit is contained in:
unanmed 2024-10-06 22:56:33 +08:00
parent e33654dac3
commit 9b718e4c93
2 changed files with 12 additions and 2 deletions

View File

@ -107,6 +107,11 @@ export class Logger {
* @param params * @param params
*/ */
error(code: number, ...params: string[]) { error(code: number, ...params: string[]) {
const info = logError[code];
if (!info) {
logger.error(16, 'error', code.toString());
return;
}
const text = this.parseInfo(logError[code], ...params); const text = this.parseInfo(logError[code], ...params);
if (this.catching) { if (this.catching) {
this.catchedInfo.push({ this.catchedInfo.push({
@ -132,6 +137,11 @@ export class Logger {
* @param text * @param text
*/ */
warn(code: number, ...params: string[]) { warn(code: number, ...params: string[]) {
const info = logWarn[code];
if (!info) {
logger.error(16, 'warn', code.toString());
return;
}
const text = this.parseInfo(logWarn[code], ...params); const text = this.parseInfo(logWarn[code], ...params);
if (this.catching) { if (this.catching) {
this.catchedInfo.push({ this.catchedInfo.push({

View File

@ -15,11 +15,11 @@
"13": "Cannot compile $1 shader. Error info: $2", "13": "Cannot compile $1 shader. Error info: $2",
"14": "Animate extension needs 'floor-hero' extension as dependency.", "14": "Animate extension needs 'floor-hero' extension as dependency.",
"15": "Viewport extension needs 'floor-hero' extension as dependency.", "15": "Viewport extension needs 'floor-hero' extension as dependency.",
"16": "Cannot find log message for $1 code $2.",
"1101": "Shadow extension needs 'floor-hero' extension as dependency.", "1101": "Shadow extension needs 'floor-hero' extension as dependency.",
"1201": "Floor-damage extension needs 'floor-binder' extension as dependency.", "1201": "Floor-damage extension needs 'floor-binder' extension as dependency.",
"1301": "Portal extension need 'floor-binder' extension as dependency.", "1301": "Portal extension need 'floor-binder' extension as dependency.",
"1401": "Halo extension needs 'floor-binder' extension as dependency.", "1401": "Halo extension needs 'floor-binder' extension as dependency."
"1501": "Cannot add listener to started chase."
}, },
"warn": { "warn": {
"1": "Resource with type of 'none' is loaded.", "1": "Resource with type of 'none' is loaded.",