diff --git a/src/connection.ts b/src/connection.ts index cc30958..a9f6cc3 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -4,7 +4,7 @@ import type { Client, ClientChannel, SFTPWrapper } from 'ssh2'; import * as vscode from 'vscode'; import { configMatches, getFlagBoolean, loadConfigs } from './config'; import type { EnvironmentVariable, FileSystemConfig } from './fileSystemConfig'; -import { Logging } from './logging'; +import { Logging, LOGGING_NO_STACKTRACE } from './logging'; import type { SSHPseudoTerminal } from './pseudoTerminal'; import type { SSHFileSystem } from './sshFileSystem'; import { mergeEnvironment, toPromise } from './utils'; @@ -137,16 +137,18 @@ export class ConnectionManager { if (!client) throw new Error(`Could not create SSH session for '${name}'`); logging.info(`Remote version: ${(client as any)._remoteVer || 'N/A'}`); // Query home directory - let home = await tryGetHome(client); - if (!home) { + let home = await tryGetHome(client).catch((e: Error) => e); + if (typeof home !== 'string') { const [flagCH] = getFlagBoolean('CHECK_HOME', true, config.flags); - logging.error('Could not detect home directory'); + logging.error('Could not detect home directory', LOGGING_NO_STACKTRACE); if (flagCH) { + if (home) logging.error(home); logging.info('If this is expected, disable the CHECK_HOME flag with \'-CHECK_HOME\':'); logging.info('https://github.com/SchoofsKelvin/vscode-sshfs/issues/270'); await vscode.window.showErrorMessage(`Couldn't detect the home directory for '${name}'`, 'Okay'); throw new Error(`Could not detect home directory`); } else { + if (home) logging.warning(home); logging.warning('The CHECK_HOME flag is disabled, default to \'/\' and ignore the error'); home = ''; } diff --git a/src/logging.ts b/src/logging.ts index 09f6474..bc3e6f8 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -130,7 +130,7 @@ class Logger { public info(message: string, options: Partial = {}) { this.print('INFO', message, options); } - public warning(message: string, options: Partial = {}) { + public warning(message: string | Error, options: Partial = {}) { this.print('WARNING', message, options); } public error(message: string | Error, options: Partial = {}) {