diff --git a/src/lib/terminal/simulator.ts b/src/lib/terminal/simulator.ts index 1c01b8c..d199d65 100644 --- a/src/lib/terminal/simulator.ts +++ b/src/lib/terminal/simulator.ts @@ -48,8 +48,15 @@ export function executeCommand( } } - if (handlerToExecute) { - return handlerToExecute(currentCode); + if (typeof handlerToExecute === "function") { + try { + return handlerToExecute(currentCode); + } catch (error) { + return { + output: `Error: command execution failed`, + exitCode: 1, + }; + } } // Built-in commands