Add FS_NOTIFY_ERRORS flag to display notifications for FS errors (fix #282)

pull/373/head
Kelvin Schoofs 3 years ago
parent 57b8ec65ba
commit cac0ec2fcc

@ -3,6 +3,9 @@
## Unreleased ## Unreleased
### New features
- Add `FS_NOTIFY_ERRORS` flag to display notifications for FS errors (#282)
### Changes ### Changes
- Small improvements to Dropdown(WithInput) UI components - Small improvements to Dropdown(WithInput) UI components

@ -5,6 +5,7 @@ import * as vscode from 'vscode';
import { ConfigLocation, FileSystemConfig, invalidConfigName, parseConnectionString } from './fileSystemConfig'; import { ConfigLocation, FileSystemConfig, invalidConfigName, parseConnectionString } from './fileSystemConfig';
import { Logging } from './logging'; import { Logging } from './logging';
import { toPromise } from './utils'; import { toPromise } from './utils';
import * as semver from 'semver';
// Logger scope with default warning/error options (which enables stacktraces) disabled // Logger scope with default warning/error options (which enables stacktraces) disabled
const logging = Logging.scope(undefined, false); const logging = Logging.scope(undefined, false);
@ -385,6 +386,9 @@ function parseFlagList(list: string[] | undefined, origin: string): Record<strin
- Enables attempting to inject a file to be sourced by the remote shells (which adds the `code` alias) - Enables attempting to inject a file to be sourced by the remote shells (which adds the `code` alias)
DEBUG_REMOTE_COMMANDS (boolean) (default=false) DEBUG_REMOTE_COMMANDS (boolean) (default=false)
- Enables debug logging for the remote command terminal (thus useless if REMOTE_COMMANDS isn't true) - Enables debug logging for the remote command terminal (thus useless if REMOTE_COMMANDS isn't true)
FS_NOTIFY_ERRORS (boolean) (default=false)
- Enables displaying error notifications when a file system operation fails and isn't automatically ignored
- Automatically enabled VS Code 1.56 and later (see issue #282)
*/ */
export type FlagValue = string | boolean | null; export type FlagValue = string | boolean | null;
export type FlagCombo<V extends FlagValue = FlagValue> = [value: V, origin: string]; export type FlagCombo<V extends FlagValue = FlagValue> = [value: V, origin: string];
@ -401,6 +405,11 @@ function calculateFlags(): Record<string, FlagCombo> {
if ((process.versions as { electron?: string }).electron?.match(/^11\.(0|1|2)\./)) { if ((process.versions as { electron?: string }).electron?.match(/^11\.(0|1|2)\./)) {
applyList(['+DF-GE'], 'Fix for issue #239') applyList(['+DF-GE'], 'Fix for issue #239')
} }
// Starting with 1.56, FileSystemProvider errors aren't shown to the user and just silently fail
// https://github.com/SchoofsKelvin/vscode-sshfs/issues/282
if (semver.gte(vscode.version, '1.56.0')) {
applyList(['+FS_NOTIFY_ERRORS'], 'Fix for issue #282');
}
applyList(config.globalValue, 'Global Settings'); applyList(config.globalValue, 'Global Settings');
applyList(config.workspaceValue, 'Workspace Settings'); applyList(config.workspaceValue, 'Workspace Settings');
applyList(config.workspaceFolderValue, 'WorkspaceFolder Settings'); applyList(config.workspaceFolderValue, 'WorkspaceFolder Settings');

@ -3,6 +3,7 @@ import * as path from 'path';
import type * as ssh2 from 'ssh2'; import type * as ssh2 from 'ssh2';
import type * as ssh2s from 'ssh2-streams'; import type * as ssh2s from 'ssh2-streams';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { getFlagBoolean } from './config';
import type { FileSystemConfig } from './fileSystemConfig'; import type { FileSystemConfig } from './fileSystemConfig';
import { Logger, Logging, LOGGING_NO_STACKTRACE, LOGGING_SINGLE_LINE_STACKTRACE, withStacktraceOffset } from './logging'; import { Logger, Logging, LOGGING_NO_STACKTRACE, LOGGING_SINGLE_LINE_STACKTRACE, withStacktraceOffset } from './logging';
@ -198,6 +199,11 @@ export class SSHFileSystem implements vscode.FileSystemProvider {
} }
if (e !== oldE) Logging.debug(`Error converted to: ${e}`); if (e !== oldE) Logging.debug(`Error converted to: ${e}`);
} }
// Display an error notification if the FS_ERROR_NOTIFICATION flag is enabled
const [flagCH] = getFlagBoolean('FS_NOTIFY_ERRORS', true, this.config.flags);
if (flagCH) {
vscode.window.showErrorMessage(`Error handling uri: ${uri}\n${e.message || e}`);
}
if (doThrow === true) throw e; if (doThrow === true) throw e;
if (doThrow) return doThrow(e); if (doThrow) return doThrow(e);
} }

Loading…
Cancel
Save