From e047e086229158cc0a199af493337244f8afff75 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 21 Aug 2020 00:12:45 +0200 Subject: [PATCH] Improved script error print --- loader/app/loader/script_loader.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/loader/app/loader/script_loader.ts b/loader/app/loader/script_loader.ts index 7d48c7d3..eb16ad31 100644 --- a/loader/app/loader/script_loader.ts +++ b/loader/app/loader/script_loader.ts @@ -107,6 +107,8 @@ export async function load_multiple(paths: SourcePath[], options: MultipleOption let prefix = ""; while(prefix.length < sname.length + 7) prefix += " "; console.log(" - %s: %s:\n%s", sname, source.message, source.stack.split("\n").map(e => prefix + e.trim()).slice(1).join("\n")); + } else if(typeof source === "string") { + console.log(" - %s: %s", sname, source); } else { console.log(" - %s: %o", sname, source); } @@ -116,18 +118,19 @@ export async function load_multiple(paths: SourcePath[], options: MultipleOption } } + let errorMessage; { const error = result.failed[0].error; - console.error(error); - let errorMessage; - if(error instanceof LoadSyntaxError) + if(error instanceof LoadSyntaxError) { errorMessage = error.source.message; - else if(typeof error === "string") + } else if(typeof error === "string") { errorMessage = error; - else + } else { + console.error("Script %s loading error: %o", script_name(result.failed[0].request, false), error); errorMessage = "View the browser console for more information!"; + } critical_error("Failed to load script " + script_name(result.failed[0].request, true), errorMessage); } - throw "failed to load script " + script_name(result.failed[0].request, false); + throw "failed to load script " + script_name(result.failed[0].request, false) + " (" + errorMessage + ")"; } } \ No newline at end of file