refactor: consolidate nodes cli error handling

This commit is contained in:
Peter Steinberger
2026-01-19 00:52:20 +00:00
parent 1fec41b3df
commit 83511c0c09
9 changed files with 65 additions and 112 deletions

View File

@@ -0,0 +1,13 @@
import { defaultRuntime } from "../../runtime.js";
import { runCommandWithRuntime } from "../cli-utils.js";
import { unauthorizedHintForMessage } from "./rpc.js";
export function runNodesCommand(label: string, action: () => Promise<void>) {
return runCommandWithRuntime(defaultRuntime, action, (err) => {
const message = String(err);
defaultRuntime.error(`nodes ${label} failed: ${message}`);
const hint = unauthorizedHintForMessage(message);
if (hint) defaultRuntime.error(hint);
defaultRuntime.exit(1);
});
}