Skip to content

Commit 15a57c7

Browse files
author
JJ Allaire
committed
improve display of dev server render errors (e.g. sass errors)
1 parent 3f1ec42 commit 15a57c7

3 files changed

Lines changed: 542 additions & 517 deletions

File tree

‎src/command/serve/serve.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,18 @@ export async function serveProject(
394394
}
395395

396396
function renderErrorPage(e: Error) {
397-
const content = e.message;
397+
const content = `
398+
<!doctype html>
399+
<html lang=en>
400+
<head>
401+
<meta charset=utf-8>
402+
<title>Quarto Render Error</title>
403+
<script id="quarto-render-error" type="text/plain">${e.message}</script>
404+
</head>
405+
<body>
406+
</body>
407+
</html>
408+
`;
398409
return new TextEncoder().encode(content);
399410
}
400411

‎src/core/dart-sass.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { join } from "path/mod.ts";
99
import { binaryPath } from "./resources.ts";
1010
import { execProcess } from "./process.ts";
1111
import { sessionTempFile } from "./temp.ts";
12+
import { lines } from "./text.ts";
1213

1314
export function dartSassInstallDir() {
1415
return binaryPath("dart-sass");
@@ -62,6 +63,10 @@ async function dartCommand(args: string[]) {
6263
if (result.success) {
6364
return result.stdout;
6465
} else {
65-
throw new Error("Theme file compilation failed:\n\n" + result.stderr);
66+
const errLines = lines(result.stderr || "");
67+
// truncate the last 2 lines (they include a pointer to the temp file containing
68+
// all of the concatenated sass, which is more or less incomprehensible for users.
69+
const errMsg = errLines.slice(0, errLines.length - 2).join("\n");
70+
throw new Error("Theme file compilation failed:\n\n" + errMsg);
6671
}
6772
}

0 commit comments

Comments
 (0)