Skip to content

Commit 4affd77

Browse files
authored
Log all compile error messages to Output channel (#1754)
1 parent d99f1d5 commit 4affd77

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

src/commands/compile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[], ask
377377
}
378378
return docs;
379379
})
380-
.catch(() => {
381-
compileErrorMsg();
380+
.catch((error) => {
381+
compileErrorMsg(error);
382382
// Always fetch server changes, even when compile failed or got cancelled
383383
return docs;
384384
})
@@ -551,7 +551,7 @@ export async function compileExplorerItems(nodes: NodeBase[]): Promise<any> {
551551
throw new Error(`${info}Compile error`);
552552
}
553553
})
554-
.catch(() => compileErrorMsg())
554+
.catch((error) => compileErrorMsg(error))
555555
);
556556
}
557557

@@ -638,7 +638,7 @@ async function promptForCompile(imported: string[], api: AtelierAPI, isIsfs: boo
638638
throw new Error(`${info}Compile error`);
639639
}
640640
})
641-
.catch(() => compileErrorMsg())
641+
.catch((error) => compileErrorMsg(error))
642642
.finally(() => {
643643
if (isIsfs) {
644644
// Refresh the files explorer to show the new files

src/providers/FileSystemProvider/FileSystemProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
914914
}
915915
data.result.content.forEach((f) => filesToUpdate.push(f.name));
916916
})
917-
.catch(() => compileErrorMsg())
917+
.catch((error) => compileErrorMsg(error))
918918
);
919919
if (file && (update || filesToUpdate.includes(file.fileName))) {
920920
// This file was just written and the write may have changed its contents or the

src/utils/index.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,25 @@ export function stringifyError(error): string {
6363
return errs.length ? `AggregateError:\n- ${errs.join("\n- ")}` : "";
6464
}
6565
return (
66-
error == undefined
67-
? ""
68-
: error.errorText
69-
? <string>error.errorText
70-
: typeof error == "string"
71-
? error
72-
: error instanceof Error
73-
? error.toString()
74-
: JSON.stringify(error)
75-
).trim();
66+
(
67+
error == undefined
68+
? ""
69+
: error.errorText
70+
? <string>error.errorText
71+
: typeof error == "string"
72+
? error
73+
: error instanceof Error
74+
? error.toString()
75+
: JSON.stringify(error)
76+
)
77+
.trim()
78+
// Unescape any HTML-escpaed characters
79+
.replaceAll("&lt;", "<")
80+
.replaceAll("&gt;", ">")
81+
.replaceAll("&quot;", '"')
82+
.replaceAll("&#39;", "'")
83+
.replaceAll("&amp;", "&")
84+
);
7685
} catch {
7786
// Need to catch errors from JSON.stringify()
7887
return "";
@@ -1017,18 +1026,12 @@ export async function replaceFile(uri: vscode.Uri, content: string | string[] |
10171026
}
10181027

10191028
/** Show the compilation failure error message if required. */
1020-
export function compileErrorMsg(): void {
1021-
vscode.window
1022-
.showErrorMessage(
1023-
"Compilation failed. Check 'ObjectScript' Output channel for details.",
1024-
!vscode.window.visibleTextEditors.some((e) => e.document.languageId == outputLangId) ? "Show" : undefined,
1025-
"Dismiss"
1026-
)
1027-
.then((action) => {
1028-
if (action == "Show") {
1029-
outputChannel.show(true);
1030-
}
1031-
});
1029+
export function compileErrorMsg(error: any): void {
1030+
handleError(
1031+
// Don't log the generic placeholder error if that's all we have
1032+
error instanceof Error && error.message.endsWith("Compile error") ? "" : error,
1033+
"Compilaton failed."
1034+
);
10321035
}
10331036

10341037
/** Return a string containing the displayable form of `uri` */

0 commit comments

Comments
 (0)