refactor: consolidate nodes cli error handling
This commit is contained in:
1 parent
1fec41b3df
commit
83511c0c09
9 files changed
+65
-112
No files matched your search
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user