Skip to content

Commit 6805b57

Browse files
R-M-Naveenclaude
andcommitted
fix(atxp): scope login hint to 401, show status codes, guard res.json
- Only show "try logging in again" for 401, not network errors - Show HTTP status code for non-401 failures, "network error" otherwise - Guard res.json() with .catch() for non-JSON responses Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ab74f76 commit 6805b57

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/atxp/src/commands/notifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async function enableNotifications(): Promise<void> {
109109
body: JSON.stringify(body),
110110
});
111111

112-
const data = await res.json() as Record<string, unknown>;
112+
const data = await res.json().catch(() => ({})) as Record<string, unknown>;
113113
if (!res.ok) {
114114
const errorMsg = (data.error as string) || res.statusText;
115115
console.error(chalk.red(`Error: ${errorMsg}`));

packages/atxp/src/commands/whoami.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ export async function whoamiCommand(): Promise<void> {
9595
if (!data) {
9696
if (accountResult.status === 401) {
9797
console.error(chalk.red('Error: Invalid or expired connection token.'));
98+
console.error(`Try logging in again: ${chalk.cyan('npx atxp login --force')}`);
99+
} else if (accountResult.status) {
100+
console.error(chalk.red(`Error: Could not fetch account info (HTTP ${accountResult.status}).`));
98101
} else {
99-
console.error(chalk.red('Error: Could not fetch account info.'));
102+
console.error(chalk.red('Error: Could not fetch account info (network error).'));
100103
}
101-
console.error(`Try logging in again: ${chalk.cyan('npx atxp login --force')}`);
102104
process.exit(1);
103105
}
104106

0 commit comments

Comments
 (0)