Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[], ask
}
return docs;
})
.catch(() => {
compileErrorMsg();
.catch((error) => {
compileErrorMsg(error);
// Always fetch server changes, even when compile failed or got cancelled
return docs;
})
Expand Down Expand Up @@ -550,7 +550,7 @@ export async function compileExplorerItems(nodes: NodeBase[]): Promise<any> {
throw new Error(`${info}Compile error`);
}
})
.catch(() => compileErrorMsg())
.catch((error) => compileErrorMsg(error))
);
}

Expand Down Expand Up @@ -637,7 +637,7 @@ async function promptForCompile(imported: string[], api: AtelierAPI, isIsfs: boo
throw new Error(`${info}Compile error`);
}
})
.catch(() => compileErrorMsg())
.catch((error) => compileErrorMsg(error))
.finally(() => {
if (isIsfs) {
// Refresh the files explorer to show the new files
Expand Down
2 changes: 1 addition & 1 deletion src/providers/FileSystemProvider/FileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
}
data.result.content.forEach((f) => filesToUpdate.push(f.name));
})
.catch(() => compileErrorMsg())
.catch((error) => compileErrorMsg(error))
);
if (file && (update || filesToUpdate.includes(file.fileName))) {
// This file was just written and the write may have changed its contents or the
Expand Down
48 changes: 26 additions & 22 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,25 @@
return errs.length ? `AggregateError:\n- ${errs.join("\n- ")}` : "";
}
return (
error == undefined
? ""
: error.errorText
? <string>error.errorText
: typeof error == "string"
? error
: error instanceof Error
? error.toString()
: JSON.stringify(error)
).trim();
(
error == undefined
? ""
: error.errorText
? <string>error.errorText
: typeof error == "string"
? error
: error instanceof Error
? error.toString()
: JSON.stringify(error)
)
.trim()
// Unescape any HTML-escpaed characters
.replaceAll("&amp;", "&")

Check failure

Code scanning / CodeQL

Double escaping or unescaping High

This replacement may produce '&' characters that are double-unescaped
here
.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
.replaceAll("&lt;", "<")
.replaceAll("&gt;", ">")
.replaceAll("&quot;", '"')
.replaceAll("&#39;", "'")
);
} catch {
// Need to catch errors from JSON.stringify()
return "";
Expand Down Expand Up @@ -1017,18 +1026,13 @@
}

/** Show the compilation failure error message if required. */
export function compileErrorMsg(): void {
vscode.window
.showErrorMessage(
"Compilation failed. Check 'ObjectScript' Output channel for details.",
!vscode.window.visibleTextEditors.some((e) => e.document.languageId == outputLangId) ? "Show" : undefined,
"Dismiss"
)
.then((action) => {
if (action == "Show") {
outputChannel.show(true);
}
});
export function compileErrorMsg(error: any): void {
if (error instanceof Error && error.message.endsWith("Compile error")) {
// Don't log the generic placeholder error
handleError("", "Compilaton failed.");
} else {
handleError(error, "Compilaton failed.");
}
}

/** Return a string containing the displayable form of `uri` */
Expand Down
Loading