Skip to content

Commit

Permalink
chore: Add StackTrace logs for Javascript error (#9694)
Browse files Browse the repository at this point in the history
chore: add stacktrace log for javascript error
  • Loading branch information
filzrev committed Feb 12, 2024
1 parent 0618405 commit 0a52387
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Docfx.Common;
using Esprima;
using Jint.Runtime;

namespace Docfx.Build.Engine;

Expand Down Expand Up @@ -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}");
}
}
}

0 comments on commit 0a52387

Please sign in to comment.