Standardize exit codes (#7055)

This commit is contained in:
Tommaso Sciortino
2025-08-25 21:44:45 -07:00
committed by GitHub
parent 415a36a195
commit 7e31577813
10 changed files with 116 additions and 97 deletions

View File

@@ -18,7 +18,7 @@ import open from 'open';
import path from 'node:path';
import { promises as fs } from 'node:fs';
import type { Config } from '../config/config.js';
import { getErrorMessage } from '../utils/errors.js';
import { getErrorMessage, FatalAuthenticationError } from '../utils/errors.js';
import { UserAccountManager } from '../utils/userAccountManager.js';
import { AuthType } from '../core/contentGenerator.js';
import readline from 'node:readline';
@@ -142,7 +142,9 @@ async function initOauthClient(
}
}
if (!success) {
process.exit(1);
throw new FatalAuthenticationError(
'Failed to authenticate with user code.',
);
}
} else {
const webLogin = await authWithWeb(client);
@@ -166,7 +168,7 @@ async function initOauthClient(
console.error(
'Failed to open browser automatically. Please try running again with NO_BROWSER=true set.',
);
process.exit(1);
throw new FatalAuthenticationError('Failed to open browser.');
});
} catch (err) {
console.error(
@@ -174,7 +176,7 @@ async function initOauthClient(
err,
'\nPlease try running again with NO_BROWSER=true set.',
);
process.exit(1);
throw new FatalAuthenticationError('Failed to open browser.');
}
console.log('Waiting for authentication...');