Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions vscode/src/ruby/asdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from "path";

import * as vscode from "vscode";

import { VersionManager, ActivationResult } from "./versionManager";
import { VersionManager, ActivationResult, NonReportableError } from "./versionManager";

// A tool to manage multiple runtime versions with a single CLI tool
//
Expand Down Expand Up @@ -82,7 +82,9 @@ export class Asdf extends VersionManager {
this.outputChannel.info(`Using configured ASDF executable path: ${asdfPath}`);
return configuredPath.fsPath;
} catch (_error: any) {
throw new Error(`ASDF executable configured as ${configuredPath.fsPath}, but that file doesn't exist`);
throw new NonReportableError(
`ASDF executable configured as ${configuredPath.fsPath}, but that file doesn't exist`,
);
}
}
}
14 changes: 10 additions & 4 deletions vscode/src/ruby/chruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import * as vscode from "vscode";

import { WorkspaceChannel } from "../workspaceChannel";

import { ActivationResult, MissingRubyError, VersionManager, ACTIVATION_SEPARATOR } from "./versionManager";
import {
ActivationResult,
MissingRubyError,
NonReportableError,
VersionManager,
ACTIVATION_SEPARATOR,
} from "./versionManager";

interface RubyVersion {
engine?: string;
Expand Down Expand Up @@ -248,13 +254,13 @@ export class Chruby extends VersionManager {
}

if (version === "") {
throw new Error(`Ruby version file ${rubyVersionUri.fsPath} is empty`);
throw new NonReportableError(`Ruby version file ${rubyVersionUri.fsPath} is empty`);
}

const match = /((?<engine>[A-Za-z]+)-)?(?<version>\d+\.\d+(\.\d+)?(-[A-Za-z0-9]+)?)/.exec(version);

if (!match?.groups) {
throw new Error(
throw new NonReportableError(
`Ruby version file ${rubyVersionUri.fsPath} contains invalid format. Expected (engine-)?version, got ${version}`,
);
}
Expand Down Expand Up @@ -433,7 +439,7 @@ export class Chruby extends VersionManager {
}

private rubyVersionError() {
return new Error(
return new NonReportableError(
`Cannot find .ruby-version file. Please specify the Ruby version in a
.ruby-version either in ${this.bundleUri.fsPath} or in a parent directory`,
);
Expand Down
4 changes: 2 additions & 2 deletions vscode/src/ruby/custom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";

import { VersionManager, ActivationResult } from "./versionManager";
import { VersionManager, ActivationResult, NonReportableError } from "./versionManager";

// Custom
//
Expand All @@ -24,7 +24,7 @@ export class Custom extends VersionManager {
const customCommand: string | undefined = configuration.get("customRubyCommand");

if (customCommand === undefined) {
throw new Error(
throw new NonReportableError(
"The customRubyCommand configuration must be set when 'custom' is selected as the version manager. \
See the [README](https://shopify.github.io/ruby-lsp/version-managers.html) for instructions.",
);
Expand Down
8 changes: 5 additions & 3 deletions vscode/src/ruby/mise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os from "os";

import * as vscode from "vscode";

import { VersionManager, ActivationResult } from "./versionManager";
import { VersionManager, ActivationResult, NonReportableError } from "./versionManager";

// Mise (mise en place) is a manager for dev tools, environment variables and tasks
//
Expand Down Expand Up @@ -33,7 +33,9 @@ export class Mise extends VersionManager {
await vscode.workspace.fs.stat(configuredPath);
return configuredPath;
} catch (_error: any) {
throw new Error(`Mise executable configured as ${configuredPath.fsPath}, but that file doesn't exist`);
throw new NonReportableError(
`Mise executable configured as ${configuredPath.fsPath}, but that file doesn't exist`,
);
}
}

Expand All @@ -57,7 +59,7 @@ export class Mise extends VersionManager {
}
}

throw new Error(
throw new NonReportableError(
`The Ruby LSP version manager is configured to be Mise, but could not find Mise installation. Searched in
${possiblePaths.join(", ")}`,
);
Expand Down
6 changes: 4 additions & 2 deletions vscode/src/ruby/rbenv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";

import { VersionManager, ActivationResult } from "./versionManager";
import { VersionManager, ActivationResult, NonReportableError } from "./versionManager";

// Seamlessly manage your app’s Ruby environment with rbenv.
//
Expand Down Expand Up @@ -36,7 +36,9 @@ export class Rbenv extends VersionManager {

return path;
} catch (_error: any) {
throw new Error(`The Ruby LSP version manager is configured to be rbenv, but ${path} does not exist`);
throw new NonReportableError(
`The Ruby LSP version manager is configured to be rbenv, but ${path} does not exist`,
);
}
}
}
4 changes: 2 additions & 2 deletions vscode/src/ruby/rv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";

import { VersionManager, ActivationResult } from "./versionManager";
import { VersionManager, ActivationResult, NonReportableError } from "./versionManager";

// Manage your Ruby environment with rv
//
Expand Down Expand Up @@ -40,7 +40,7 @@ export class Rv extends VersionManager {
await vscode.workspace.fs.stat(vscode.Uri.file(path));
return path;
} catch (_error: any) {
throw new Error(`The Ruby LSP version manager is configured to be rv, but ${path} does not exist`);
throw new NonReportableError(`The Ruby LSP version manager is configured to be rv, but ${path} does not exist`);
}
}
}
4 changes: 2 additions & 2 deletions vscode/src/ruby/rvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os from "os";

import * as vscode from "vscode";

import { ActivationResult, VersionManager } from "./versionManager";
import { ActivationResult, NonReportableError, VersionManager } from "./versionManager";

// Ruby enVironment Manager. It manages Ruby application environments and enables switching between them.
// Learn more:
Expand Down Expand Up @@ -43,7 +43,7 @@ export class Rvm extends VersionManager {
}
}

throw new Error(
throw new NonReportableError(
`Cannot find RVM installation directory. Searched in ${possiblePaths.map((uri) => uri.fsPath).join(",")}`,
);
}
Expand Down
6 changes: 3 additions & 3 deletions vscode/src/ruby/shadowenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Shadowenv extends VersionManager {
try {
await vscode.workspace.fs.stat(vscode.Uri.joinPath(this.bundleUri, ".shadowenv.d"));
} catch (_error: any) {
throw new Error(
throw new NonReportableError(
"The Ruby LSP version manager is configured to be shadowenv, \
but no .shadowenv.d directory was found in the workspace",
);
Expand Down Expand Up @@ -58,15 +58,15 @@ export class Shadowenv extends VersionManager {
try {
await asyncExec("shadowenv --version");
} catch (_error: any) {
throw new Error(
throw new NonReportableError(
`Shadowenv executable not found. Ensure it is installed and available in the PATH.
This error may happen if your shell configuration is failing to be sourced from the editor or if
another extension is mutating the process PATH.`,
);
}

// If it failed for some other reason, present the error to the user
throw new Error(`Failed to activate Ruby environment with Shadowenv: ${error.message}`);
throw new NonReportableError(`Failed to activate Ruby environment with Shadowenv: ${error.message}`);
}
}
}