@@ -46,6 +46,8 @@ const secretsApplyLoader = createLazyImportLoader<SecretsApplyModule>(
4646 () => import("../secrets/apply.js"),
4747);
4848
49+ class SecretsPlanFileNotFoundError extends Error {}
50+
4951async function readPlanFile(pathname: string): Promise<SecretsApplyPlan> {
5052 // Apply consumes a generated plan shape, not arbitrary JSON.
5153 const [{ readFileSync }, { isSecretsApplyPlan }] = await Promise.all([
@@ -57,7 +59,9 @@ async function readPlanFile(pathname: string): Promise<SecretsApplyPlan> {
5759 raw = readFileSync(pathname, "utf8");
5860 } catch (err) {
5961 if (hasErrnoCode(err, "ENOENT")) {
60- throw new Error(`Secrets plan file not found: ${pathname}`, { cause: err });
62+ throw new SecretsPlanFileNotFoundError(`Secrets plan file not found: ${pathname}`, {
63+ cause: err,
64+ });
6165 }
6266 throw err;
6367 }
@@ -341,10 +345,10 @@ export function registerSecretsCli(program: Command): void {
341345 : "Secrets apply: no changes.",
342346 );
343347 } catch (err) {
344- // The missing-plan wrapper already carries a user-friendly message; keep its
345- // ENOENT cause out of the rendered CLI output while preserving it for diagnostics .
348+ // The missing-plan wrapper already carries a user-facing message. Keep its
349+ // ENOENT cause available to diagnostics without rendering the raw filesystem error .
346350 const message =
347- err instanceof Error && err.message.startsWith("Secrets plan file not found")
351+ err instanceof SecretsPlanFileNotFoundError
348352 ? err.message
349353 : formatErrorMessage(err);
350354 defaultRuntime.error(
0 commit comments