Skip to content

Commit 709adac

Browse files
authored
Merge pull request #588 from hasufell/issue-587
Improve error message, fixes #587
2 parents 0caa639 + c373cc2 commit 709adac

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/errors.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export class MissingToolError extends HlsError {
5151

5252
export class NoMatchingHls extends Error {
5353
constructor(readonly ghcProjVersion: string) {
54-
const noMatchingHLS = `No HLS version was found for supporting GHC ${ghcProjVersion}.`;
55-
super(noMatchingHLS);
54+
super(`HLS does not support GHC ${ghcProjVersion} yet.`);
55+
}
56+
public docLink(): Uri {
57+
return Uri.parse('https://haskell-language-server.readthedocs.io/en/latest/supported-versions.html');
5658
}
5759
}

src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import { CommandNames } from './commands/constants';
2424
import { ImportIdentifier } from './commands/importIdentifier';
2525
import { DocsBrowser } from './docsBrowser';
26-
import { HlsError, MissingToolError } from './errors';
26+
import { HlsError, MissingToolError, NoMatchingHls } from './errors';
2727
import { findHaskellLanguageServer, IEnvVars } from './hlsBinaries';
2828
import { addPathToProcessPath, expandHomeDir, ExtensionLogger } from './utils';
2929

@@ -176,6 +176,12 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
176176
} else if (e instanceof HlsError) {
177177
logger.error(`General HlsError: ${e.message}`);
178178
window.showErrorMessage(e.message);
179+
} else if (e instanceof NoMatchingHls) {
180+
const link = e.docLink();
181+
logger.error(`${e.message}`);
182+
if (await window.showErrorMessage(e.message, `Open documentation`)) {
183+
env.openExternal(link);
184+
}
179185
} else if (e instanceof Error) {
180186
logger.error(`Internal Error: ${e.message}`);
181187
window.showErrorMessage(e.message);

0 commit comments

Comments
 (0)