fix(command-node): enhance error message formatting in command execution

- Improved error message handling by assigning the stderr output to a variable for better readability.
- Ensured consistent error reporting when a command fails, maintaining clarity in the output.
This commit is contained in:
Harry 2026-01-08 11:14:37 +08:00
parent 1fbba38436
commit 0d33714f28

View File

@ -111,11 +111,14 @@ class CommandNode(Node[CommandNodeData]):
process_data = {"command": command, "working_directory": working_directory}
if result.exit_code not in (None, 0):
error_message = (
f"{result.stderr.decode('utf-8', errors='replace')}\n\nCommand exited with code {result.exit_code}"
)
return NodeRunResult(
status=WorkflowNodeExecutionStatus.FAILED,
outputs=outputs,
process_data=process_data,
error=f"{result.stderr.decode('utf-8', errors='replace')}\n\nCommand exited with code {result.exit_code}",
error=error_message,
error_type=CommandExecutionError.__name__,
)