perf: 优化主机登录失败提示

This commit is contained in:
xiaojunnuo
2024-09-20 11:11:25 +08:00
parent ab41eea7a9
commit 9de77b327d
4 changed files with 22 additions and 10 deletions

View File

@@ -286,7 +286,16 @@ export class SshClient {
async _call(options: { connectConf: SshAccess; callable: any }): Promise<string[]> {
const { connectConf, callable } = options;
const conn = new AsyncSsh2Client(connectConf, this.logger);
await conn.connect();
try {
await conn.connect();
} catch (e: any) {
if (e.message?.indexOf('All configured authentication methods failed') > -1) {
this.logger.error(e);
throw new Error('登录失败,请检查用户名/密码/密钥是否正确');
}
throw e;
}
try {
return await callable(conn);
} finally {