mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Standardize exit codes (#7055)
This commit is contained in:
committed by
GitHub
parent
415a36a195
commit
7e31577813
@@ -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...');
|
||||
|
||||
|
||||
@@ -25,6 +25,41 @@ export function getErrorMessage(error: unknown): string {
|
||||
}
|
||||
}
|
||||
|
||||
export class FatalError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
readonly exitCode: number,
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export class FatalAuthenticationError extends FatalError {
|
||||
constructor(message: string) {
|
||||
super(message, 41);
|
||||
}
|
||||
}
|
||||
export class FatalInputError extends FatalError {
|
||||
constructor(message: string) {
|
||||
super(message, 42);
|
||||
}
|
||||
}
|
||||
export class FatalSandboxError extends FatalError {
|
||||
constructor(message: string) {
|
||||
super(message, 44);
|
||||
}
|
||||
}
|
||||
export class FatalConfigError extends FatalError {
|
||||
constructor(message: string) {
|
||||
super(message, 52);
|
||||
}
|
||||
}
|
||||
export class FatalTurnLimitedError extends FatalError {
|
||||
constructor(message: string) {
|
||||
super(message, 53);
|
||||
}
|
||||
}
|
||||
|
||||
export class ForbiddenError extends Error {}
|
||||
export class UnauthorizedError extends Error {}
|
||||
export class BadRequestError extends Error {}
|
||||
|
||||
Reference in New Issue
Block a user