From 29ff3b5bdbf23a4e93c083e387fbea605a57a5e7 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 12 Feb 2024 11:08:58 +0900 Subject: [PATCH] chore: Add StackTrace logs for Javascript error (#9694) chore: add stacktrace log for javascript error --- .../Preprocessors/PreprocessorWithResourcePool.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorWithResourcePool.cs b/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorWithResourcePool.cs index 03ecc99638b..485ff4048cd 100644 --- a/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorWithResourcePool.cs +++ b/src/Docfx.Build/TemplateProcessors/Preprocessors/PreprocessorWithResourcePool.cs @@ -3,6 +3,7 @@ using Docfx.Common; using Esprima; +using Jint.Runtime; namespace Docfx.Build.Engine; @@ -71,9 +72,13 @@ public object TransformModel(object model) { return lease.Resource.TransformModel(model); } - catch (Exception e) + catch (Exception ex) { - throw new InvalidPreprocessorException($"Error running Transform function inside template preprocessor: {e.Message}"); + string message = ex is JavaScriptException jsException + ? jsException.GetJavaScriptErrorString() + : ex.Message; + + throw new InvalidPreprocessorException($"Error running Transform function inside template preprocessor: {message}"); } } }