From a2f30f5cfcb8b0deabf25d49d5f517e8c7a7934a Mon Sep 17 00:00:00 2001 From: Mari Date: Sat, 4 May 2024 00:51:58 -0700 Subject: [PATCH] Move logging to loadCharacters --- src/commands/base.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/commands/base.ts b/src/commands/base.ts index 13c391d..0754ba2 100644 --- a/src/commands/base.ts +++ b/src/commands/base.ts @@ -212,7 +212,10 @@ export abstract class AbstractCharacterStatusCommand extends SlashCommand { Array.from(names).map((name) => loadCharacter(this.dataDir, name) .then((c) => ({ name, success: true, originalData: c })) - .catch((e) => ({ name, success: false, error: e })) + .catch((e) => { + console.error(`While loading ${name}: `, e) + return { name, success: false, error: e } + }) ) ); } @@ -229,11 +232,6 @@ export abstract class AbstractCharacterStatusCommand extends SlashCommand { } } const loadedCharacters = await this.loadCharacters(neededCharacters); - for (const char of loadedCharacters) { - if (!char.success) { - console.error(`While loading ${char.name}: `, char.error) - } - } const characterMap = new Map(); for (const character of loadedCharacters) { characterMap.set(character.name, character);