Skip to content

Commit 18cd188

Browse files
committed
Log all compile error messages to Output channel
1 parent 17eaba4 commit 18cd188

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/commands/compile.ts

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

@@ -637,7 +637,7 @@ async function promptForCompile(imported: string[], api: AtelierAPI, isIsfs: boo
637637
throw new Error(`${info}Compile error`);
638638
}
639639
})
640-
.catch(() => compileErrorMsg())
640+
.catch((error) => compileErrorMsg(error))
641641
.finally(() => {
642642
if (isIsfs) {
643643
// 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: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ export function stringifyError(error): string {
7272
: error instanceof Error
7373
? error.toString()
7474
: JSON.stringify(error)
75-
).trim();
75+
)
76+
.trim()
77+
// Unescape any HTML-escpaed characters
78+
.replaceAll("&amp;", "&")
79+
.replaceAll("&lt;", "<")
80+
.replaceAll("&gt;", ">")
81+
.replaceAll("&quot;", '"')
82+
.replaceAll("&#39;", "'");
7683
} catch {
7784
// Need to catch errors from JSON.stringify()
7885
return "";
@@ -1017,7 +1024,11 @@ export async function replaceFile(uri: vscode.Uri, content: string | string[] |
10171024
}
10181025

10191026
/** Show the compilation failure error message if required. */
1020-
export function compileErrorMsg(): void {
1027+
export function compileErrorMsg(error: any): void {
1028+
if (!(error instanceof Error && error.message.endsWith("Compile error"))) {
1029+
// Don't log the generic placeholder error
1030+
handleError(error);
1031+
}
10211032
vscode.window
10221033
.showErrorMessage(
10231034
"Compilation failed. Check 'ObjectScript' Output channel for details.",

0 commit comments

Comments
 (0)