Skip to content
Draft
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
4 changes: 2 additions & 2 deletions cli/src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function loginInternal(apikey: string, options: Options, silent = f
if (!apikey) {
if (!silent)
log.error('Missing API key, you need to provide an API key to upload your bundle')
throw new Error('Missing API key')
throw new CliUserError('Missing API key')
}

if (!silent)
Expand All @@ -47,7 +47,7 @@ export async function loginInternal(apikey: string, options: Options, silent = f
if (local && !existsSync('.git')) {
if (!silent)
log.error('To use local you should be in a git repository')
throw new Error('Not in a git repository')
throw new CliUserError('Not in a git repository')
}

// Validate, persist (0o600) and emit the login event via the shared auth core.
Expand Down
3 changes: 3 additions & 0 deletions cli/test/test-posthog-exception.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ try {
// never opens an error tracking issue.
assert.equal(shouldCapturePosthogException(new CliUserError('Login cancelled')), false)
assert.equal(shouldCapturePosthogException(new CliUserError('Upload cancelled by user')), false)
// `login --local` outside a git repository is a normal user mistake the CLI
// already handles cleanly, so it throws CliUserError and never opens an issue.
assert.equal(shouldCapturePosthogException(new CliUserError('Not in a git repository')), false)
// Two failures on different channels must be treated identically (one issue,
// not one per channel), since the channel name lives in context, not the message.
assert.equal(
Expand Down
Loading