Skip to content

Commit e7d86d1

Browse files
authored
(fix) always show svelte.config.js parser error (#423)
Was swallowed in some cases #422
1 parent 5cbdbc0 commit e7d86d1

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

packages/language-server/src/plugins/svelte/features/getDiagnostics.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ export async function getDiagnostics(
1212
document: Document,
1313
svelteDoc: SvelteDocument,
1414
): Promise<Diagnostic[]> {
15+
if (svelteDoc.config.loadConfigError) {
16+
return getConfigLoadErrorDiagnostics(svelteDoc.config.loadConfigError);
17+
}
18+
1519
try {
1620
return await tryGetDiagnostics(document, svelteDoc);
1721
} catch (error) {
18-
return getPreprocessErrorDiagnostics(document, svelteDoc, error);
22+
return getPreprocessErrorDiagnostics(document, error);
1923
}
2024
}
2125

@@ -91,18 +95,10 @@ async function createParserErrorDiagnostic(error: any, document: Document) {
9195
/**
9296
* Try to infer a nice diagnostic error message from the transpilation error.
9397
*/
94-
function getPreprocessErrorDiagnostics(
95-
document: Document,
96-
svelteDoc: SvelteDocument,
97-
error: any,
98-
): Diagnostic[] {
98+
function getPreprocessErrorDiagnostics(document: Document, error: any): Diagnostic[] {
9999
Logger.error('Preprocessing failed');
100100
Logger.error(error);
101101

102-
if (svelteDoc.config.loadConfigError) {
103-
return getConfigLoadErrorDiagnostics(svelteDoc.config.loadConfigError);
104-
}
105-
106102
if (document.styleInfo && error.__source === TranspileErrorSource.Style) {
107103
return getStyleErrorDiagnostics(error, document);
108104
}

0 commit comments

Comments
 (0)