diff --git a/packages/core/src/stellar-cli/check-stellar-cli-version.test.ts b/packages/core/src/stellar-cli/check-stellar-cli-version.test.ts index b937a084..ec3c0fc0 100644 --- a/packages/core/src/stellar-cli/check-stellar-cli-version.test.ts +++ b/packages/core/src/stellar-cli/check-stellar-cli-version.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; -import { CaatingaErrorCode } from "../errors/CaatingaError.js"; +import { CaatingaError, CaatingaErrorCode } from "../errors/CaatingaError.js"; const runCommandMock = vi.hoisted(() => vi.fn()); @@ -83,7 +83,13 @@ describe("checkStellarCliVersion", () => { }); it("normalizes missing stellar binary to CAATINGA_STELLAR_CLI_NOT_FOUND", async () => { - runCommandMock.mockRejectedValueOnce(Object.assign(new Error("not found"), { code: "ENOENT" })); + runCommandMock.mockRejectedValueOnce( + new CaatingaError( + "Stellar CLI was not found.", + CaatingaErrorCode.STELLAR_CLI_NOT_FOUND, + "Install Stellar CLI before running Caatinga-backed commands." + ) + ); await expect(checkStellarCliVersion()).rejects.toMatchObject({ code: CaatingaErrorCode.STELLAR_CLI_NOT_FOUND, diff --git a/packages/core/src/stellar-cli/check-stellar-cli-version.ts b/packages/core/src/stellar-cli/check-stellar-cli-version.ts index 9f3ae244..a7a88903 100644 --- a/packages/core/src/stellar-cli/check-stellar-cli-version.ts +++ b/packages/core/src/stellar-cli/check-stellar-cli-version.ts @@ -1,4 +1,3 @@ -import { CaatingaError, CaatingaErrorCode } from "../errors/CaatingaError.js"; import { runCommand } from "../shell/run-command.js"; import { evaluateStellarCliCompatibility, @@ -21,23 +20,10 @@ export async function checkStellarCliVersion( ): Promise { let rawOutput: string; - try { - const result = await runCommand("stellar", ["--version"], { - skipStellarVersionCheck: true, - }); - rawOutput = result.all || result.stdout || result.stderr; - } catch (error) { - if (typeof error === "object" && error && "code" in error && error.code === "ENOENT") { - throw new CaatingaError( - "Stellar CLI was not found.", - CaatingaErrorCode.STELLAR_CLI_NOT_FOUND, - "Install Stellar CLI before running Caatinga-backed commands.", - error - ); - } - - throw error; - } + const result = await runCommand("stellar", ["--version"], { + skipStellarVersionCheck: true, + }); + rawOutput = result.all || result.stdout || result.stderr; const version = parseStellarCliVersion(rawOutput); const probedMissing =