-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: show upgrade nudge when command fails and newer version exists #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c013538
1edc6ee
8296b5e
3702653
ef582a5
9798a7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -754,6 +754,51 @@ export function getExitCode(error: unknown): number { | |
| return 1; | ||
| } | ||
|
|
||
| /** | ||
| * Classify errors caused by user input, configuration, auth state, or account | ||
| * settings. These errors already tell the user what to fix, so upgrade nudges | ||
| * should use the neutral update banner instead of implying a CLI bug fix. | ||
| * | ||
| * Generic {@link CliError} instances are treated as user-facing by default. | ||
| * Explicit non-user subclasses must be checked before that fallback. | ||
| */ | ||
| export function isUserError(error: unknown): boolean { | ||
| if (error instanceof ApiError) { | ||
| // Status 0 = network-level failure (DNS, ECONNREFUSED) — user environment, | ||
| // not a CLI bug. 400 usually means the CLI constructed a bad request. | ||
| // Other 4xx statuses are user/account/API-state problems. | ||
| if (error.status === 0) { | ||
| return true; | ||
| } | ||
| return error.status > 400 && error.status < 500; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Network errors get misleading upgrade nudge messageLow Severity
Reviewed by Cursor Bugbot for commit 3702653. Configure here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch — |
||
|
|
||
| if ( | ||
| error instanceof AbortError || | ||
| error instanceof TimeoutError || | ||
| error instanceof UpgradeError | ||
| ) { | ||
| return false; | ||
| } | ||
|
|
||
| if ( | ||
| error instanceof AuthError || | ||
| error instanceof HostScopeError || | ||
| error instanceof ConfigError || | ||
| error instanceof ContextError || | ||
| error instanceof ResolutionError || | ||
| error instanceof ValidationError || | ||
| error instanceof DeviceFlowError || | ||
| error instanceof SeerError || | ||
| error instanceof OutputError || | ||
| error instanceof WizardError | ||
| ) { | ||
| return true; | ||
| } | ||
|
|
||
| return error instanceof CliError; | ||
| } | ||
|
|
||
| /** Result when the guarded operation succeeded */ | ||
| export type AuthGuardSuccess<T> = { ok: true; value: T }; | ||
|
|
||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.