Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion package/scripts/common/quarto
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ if [ -f "$DEV_PATH" ]; then
fi
export QUARTO_BIN_PATH=$SCRIPT_PATH
export QUARTO_SHARE_PATH="${QUARTO_SHARE_PATH=$QUARTO_SRC_PATH/resources/}"
export QUARTO_DEBUG=true
if [ -z ${QUARTO_DEBUG+x} ]; then
export QUARTO_DEBUG=true
fi
QUARTO_CACHE_OPTIONS="--cached-only"

# Check for deno update
Expand Down
5 changes: 4 additions & 1 deletion package/scripts/windows/quarto.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ IF EXIST "!QUARTO_TS_PATH!" (
SET "QUARTO_TARGET=!QUARTO_TS_PATH!"
)

SET QUARTO_DEBUG=true
IF NOT DEFINED QUARTO_DEBUG (
SET QUARTO_DEBUG=true
)

:: Normalize path to remove ../.. stuff
for %%i in ("!SCRIPT_PATH!..\config\deno-version") do SET "DENO_VERSION_FILE=%%~fi"

Expand Down
4 changes: 2 additions & 2 deletions src/core/lib/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export class ErrorEx extends Error {
public readonly printStack: boolean;
}

export function asErrorEx(e: unknown) {
export function asErrorEx(e: unknown, defaultShowStack = true) {
if (e instanceof ErrorEx) {
return e;
} else if (e instanceof Error) {
// ammend this error rather than creating a new ErrorEx
// so that the stack trace survives

(e as any).printName = e.name !== "Error";
(e as any).printStack = !!e.message;
(e as any).printStack = defaultShowStack && !!e.message;
return e as ErrorEx;
} else {
return new ErrorEx("Error", String(e), false, true);
Expand Down
5 changes: 3 additions & 2 deletions src/core/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface LogMessageOptions {

// deno-lint-ignore no-explicit-any
export function appendLogOptions(cmd: Command<any>): Command<any> {
// deno-lint-ignore no-explicit-any
const addLogOptions = (cmd: Command<any>) => {
return cmd.option(
"--log <file>",
Expand Down Expand Up @@ -315,9 +316,9 @@ export function logProgress(message: string) {
log.info(colors.bold(colors.blue(message)));
}

export function logError(e: unknown) {
export function logError(e: unknown, defaultShowStack = true) {
// normalize
const err = asErrorEx(e);
const err = asErrorEx(e, defaultShowStack);

// print error name if requested
let message = err.printName ? `${err.name}: ${err.message}` : err.message;
Expand Down
12 changes: 11 additions & 1 deletion src/quarto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { quartoConfig } from "./core/quarto.ts";
import { execProcess } from "./core/process.ts";
import { pandocBinaryPath } from "./core/resources.ts";
import { appendProfileArg, setProfileFromArg } from "./quarto-core/profile.ts";
import { logError } from "./core/log.ts";
import { CommandError } from "cliffy/command/_errors.ts";

import {
devConfigsEqual,
Expand Down Expand Up @@ -153,7 +155,15 @@ export async function quarto(
}
}

await promise;
try {
await promise;
} catch (e) {
if (e instanceof CommandError) {
logError(e, false);
} else {
throw e;
}
}
}

if (import.meta.main) {
Expand Down