refactor: replace string-matching error checks with custom error classes
This commit is contained in:
@@ -12,6 +12,7 @@ import type {
|
||||
} from "vscode-languageserver-protocol";
|
||||
import * as path from "node:path";
|
||||
import type { ServerConfig } from "./types.ts";
|
||||
import { ServerNotFoundError } from "./types.ts";
|
||||
import { findRoot, pathToUri, uriToPath } from "./root.ts";
|
||||
|
||||
// Is On PATH - Returns true if `cmd` resolves to an executable via the
|
||||
@@ -73,10 +74,7 @@ export class LspClient {
|
||||
// letting spawn ENOENT surface as a generic error. It's the user's
|
||||
// responsibility to have the server installed & on PATH.
|
||||
if (!isOnPath(this.server.command)) {
|
||||
throw new Error(
|
||||
`LSP server binary "${this.server.command}" not found on PATH. ` +
|
||||
`Install it and ensure it's on your PATH (required by server "${this.server.id}").`,
|
||||
);
|
||||
throw new ServerNotFoundError(this.server.command);
|
||||
}
|
||||
this.proc = spawn(this.server.command, this.server.args, {
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
|
||||
Reference in New Issue
Block a user