Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/connectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class ConnectCommand {
await displayErrorAndExit(
new CapyError(
`${(err as Error).message}\nRun \`capy connect\` to see available providers.`,
ERROR_CODES.INVALID_FORMAT,
ERROR_CODES.PROVIDER_NOT_FOUND,
),
);
return { linked: false };
Expand Down
19 changes: 15 additions & 4 deletions src/commands/pushCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,15 @@ export class PushCommand {
userId: projectState.userId,
});
if (!projectState.initialized) {
console.error(`No keep.lock file found. Run ${B('capy')} first to initialize.`);
process.exit(1);
// THROW, never console.error + process.exit. `execute()`'s catch routes to
// `displayErrorAndExit`, which serves the command-error page under `--web`.
// `push` takes no `web` option and needs none: that function reads web mode
// itself. Exiting here never threw, so the catch never ran and a --web
// caller got a refusal on a stream with nobody on the other end.
throw new CapyError(
`No keep.lock file found. Run ${B('capy')} first to initialize.`,
ERROR_CODES.PROJECT_NOT_INITIALIZED,
);
}

// Local-only mode: no auth, no server push. `capy push` becomes a local
Expand Down Expand Up @@ -140,8 +147,12 @@ export class PushCommand {
variables: Object.keys(keep.variables),
} : 'NOT FOUND');
if (!keep) {
console.error('No keep.lock file found.');
process.exit(1);
// THROW, never console.error + process.exit. `execute()`'s catch routes to
// `displayErrorAndExit`, which serves the command-error page under `--web`.
// `push` takes no `web` option and needs none: that function reads web mode
// itself. Exiting here never threw, so the catch never ran and a --web
// caller got a refusal on a stream with nobody on the other end.
throw new CapyError('No keep.lock file found.', ERROR_CODES.NO_KEEP_FILE);
}

const branch = projectState.activeBranch;
Expand Down
7 changes: 7 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ export const ERROR_CODES = {
QUOTA_EXCEEDED: 'QUOTA_EXCEEDED',
// not-found family — replaces server-prose string matching in serviceClient
PROJECT_NOT_FOUND: 'PROJECT_NOT_FOUND',
// `capy connect <name>` names a provider this build does not have. A
// not-found condition, not a malformed one: the remedy is to pick from the
// list, where a syntax error's remedy is to correct the input. Minted rather
// than folded into INVALID_FORMAT for the reason KEY_NOT_ON_DEVICE gives —
// the remedies differ, and nothing may distinguish them by reading the
// message.
PROVIDER_NOT_FOUND: 'PROVIDER_NOT_FOUND',
// The signed-in account belongs to no organization at all. Distinct from
// PROJECT_NOT_FOUND and from a permission refusal: there is nothing to pick
// from, so no amount of re-authenticating or re-scoping helps.
Expand Down
Loading