Skip to content

Commit 11787f0

Browse files
committed
Update index.ts
1 parent 18cd188 commit 11787f0

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

src/utils/index.ts

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +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-
)
76-
.trim()
77-
// Unescape any HTML-escpaed characters
78-
.replaceAll("&amp;", "&")
79-
.replaceAll("&lt;", "<")
80-
.replaceAll("&gt;", ">")
81-
.replaceAll("&quot;", '"')
82-
.replaceAll("&#39;", "'");
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("&amp;", "&")
80+
.replaceAll("&lt;", "<")
81+
.replaceAll("&gt;", ">")
82+
.replaceAll("&quot;", '"')
83+
.replaceAll("&#39;", "'")
84+
);
8385
} catch {
8486
// Need to catch errors from JSON.stringify()
8587
return "";
@@ -1025,21 +1027,12 @@ export async function replaceFile(uri: vscode.Uri, content: string | string[] |
10251027

10261028
/** Show the compilation failure error message if required. */
10271029
export function compileErrorMsg(error: any): void {
1028-
if (!(error instanceof Error && error.message.endsWith("Compile error"))) {
1030+
if (error instanceof Error && error.message.endsWith("Compile error")) {
10291031
// Don't log the generic placeholder error
1030-
handleError(error);
1032+
handleError("", "Compilaton failed.");
1033+
} else {
1034+
handleError(error, "Compilaton failed.");
10311035
}
1032-
vscode.window
1033-
.showErrorMessage(
1034-
"Compilation failed. Check 'ObjectScript' Output channel for details.",
1035-
!vscode.window.visibleTextEditors.some((e) => e.document.languageId == outputLangId) ? "Show" : undefined,
1036-
"Dismiss"
1037-
)
1038-
.then((action) => {
1039-
if (action == "Show") {
1040-
outputChannel.show(true);
1041-
}
1042-
});
10431036
}
10441037

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

0 commit comments

Comments
 (0)