mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
feat: When console login is not performed, throw more explicit errors and prompts
This commit is contained in:
@@ -22,7 +22,10 @@ function alignContinuation(text: string): string {
|
||||
|
||||
function enhanceHint(err: BailianError): string | undefined {
|
||||
if (err.exitCode === ExitCode.AUTH) {
|
||||
if (err.message === CONSOLE_GATEWAY_NO_TOKEN_MESSAGE) {
|
||||
if (
|
||||
err.message === CONSOLE_GATEWAY_NO_TOKEN_MESSAGE ||
|
||||
err.hint?.includes("auth login --console")
|
||||
) {
|
||||
return err.hint;
|
||||
}
|
||||
return [
|
||||
|
||||
@@ -78,10 +78,19 @@ export async function callConsoleGateway(
|
||||
|
||||
const innerData = json.data as Record<string, unknown> | undefined;
|
||||
if (innerData?.success === false && innerData.errorCode) {
|
||||
const errorCode = String(innerData.errorCode);
|
||||
const notLogined = errorCode.includes("NotLogined");
|
||||
const errorMsg = typeof innerData.errorMsg === "string" ? innerData.errorMsg : undefined;
|
||||
throw new BailianError(
|
||||
`Console gateway error: ${innerData.errorCode}`,
|
||||
ExitCode.GENERAL,
|
||||
typeof innerData.errorMsg === "string" ? innerData.errorMsg : undefined,
|
||||
notLogined
|
||||
? "Console session is not logged in or has expired."
|
||||
: `Console gateway error: ${errorCode}`,
|
||||
notLogined ? ExitCode.AUTH : ExitCode.GENERAL,
|
||||
notLogined
|
||||
? "Run `bl auth login --console` to sign in or refresh your console session."
|
||||
: errorMsg && errorMsg !== errorCode
|
||||
? errorMsg
|
||||
: undefined,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user