diff --git a/src/Errors/EleventyErrorHandler.js b/src/Errors/EleventyErrorHandler.js index bd3d64830..90ad4dc34 100644 --- a/src/Errors/EleventyErrorHandler.js +++ b/src/Errors/EleventyErrorHandler.js @@ -91,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) { + nextRef.originalError = nextRef.cause?.originalError || nextRef?.cause; } if (!nextRef && EleventyErrorUtil.hasEmbeddedError(ref.message)) {