From 7615d6efb14a407535a306bc23e67927a4ec2968 Mon Sep 17 00:00:00 2001
From: clauspeterhuebner
Date: Tue, 10 Feb 2026 00:05:44 +0100
Subject: [PATCH] surround command instanciation with try-catch
---
core/src/command/CommandFactory.ts | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/core/src/command/CommandFactory.ts b/core/src/command/CommandFactory.ts
index 7f39d3b02..cc62681e9 100644
--- a/core/src/command/CommandFactory.ts
+++ b/core/src/command/CommandFactory.ts
@@ -38,17 +38,24 @@ export class CommandFactory {
}
const CommandClass = this.commands.get(name);
if (methodLogger.isDebugEnabled()) {
- methodLogger.debug(`createCommand() name=${name} commandClass=${CommandClass ? CommandClass.name : 'null'}`)
+ methodLogger.debug(`createCommand() name=${name} commandClass=${CommandClass ? JSON.stringify(CommandClass) : 'null'}`)
}
if (!CommandClass) {
const errmsg = `Command ${name} not found`;
methodLogger.error(errmsg);
throw new Error(errmsg);
}
- const command = new CommandClass(params) as Command;
- if (methodLogger.isDebugEnabled()) {
- methodLogger.debug(`createCommand() command=${JSON.stringify(command)}`)
+ try {
+ const command = new CommandClass(params) as Command;
+ if (methodLogger.isDebugEnabled()) {
+ methodLogger.debug(`createCommand() command=${JSON.stringify(command)}`)
+ }
+ return command;
+ } catch (error) {
+ const errmsg = `Failed to create command ${name}: ${error instanceof Error ? error.message : 'Unknown error'}`;
+ methodLogger.error(errmsg);
+ throw new Error(errmsg);
}
- return command;
+
}
}