Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error stack improvements #3572

Merged
merged 6 commits into from
Dec 11, 2024
Merged
Changes from 3 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
9 changes: 4 additions & 5 deletions src/Errors/EleventyErrorHandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import util from "node:util";
import debugUtil from "debug";

import ConsoleLogger from "../Util/ConsoleLogger.js";
Expand Down Expand Up @@ -77,7 +76,7 @@ class EleventyErrorHandler {
//https://nodejs.org/api/process.html
log(e, type = "log", chalkColor = "", forceToConsole = false) {
if (process.env.DEBUG) {
debug("Full error object: %o", util.inspect(e, { showHidden: false, depth: null }));
debug("Full error object: %O", e);
}
zachleat marked this conversation as resolved.
Show resolved Hide resolved

let showStack = true;
Expand All @@ -92,9 +91,9 @@ class EleventyErrorHandler {
while (ref) {
let nextRef = ref.originalError;

// Nunjucks wraps errors and puts the original in error.cause
if (nextRef?.cause?.originalError) {
nextRef = nextRef.cause.originalError;
// Unwrap cause from error and assign it to what Eleventy expects
if (nextRef?.cause) {
zachleat marked this conversation as resolved.
Show resolved Hide resolved
nextRef.originalError = nextRef.cause?.originalError ?? nextRef?.cause;
}

if (!nextRef && EleventyErrorUtil.hasEmbeddedError(ref.message)) {
Expand Down
Loading