From 8ae320912348c162d2b90f1dc7b7528999bbb305 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 6 Jun 2018 14:22:39 +0000 Subject: Better error reporting on XFA JS errors Change-Id: I773ff83b45ffbd736f064daedb1010c8d01a99d5 Reviewed-on: https://pdfium-review.googlesource.com/34050 Commit-Queue: dsinclair Reviewed-by: dsinclair --- fxjs/cfxjse_context.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp index 2de698d3ed..01f86c37be 100644 --- a/fxjs/cfxjse_context.cpp +++ b/fxjs/cfxjse_context.cpp @@ -293,7 +293,16 @@ bool CFXJSE_Context::ExecuteScript(const char* szScript, #ifndef NDEBUG v8::String::Utf8Value error(GetIsolate(), trycatch.Exception()); - fprintf(stderr, "JS Error: %ls\n", WideString::FromUTF8(*error).c_str()); + fprintf(stderr, "JS Error: %s\n", *error); + + v8::Local message = trycatch.Message(); + if (!message.IsEmpty()) { + v8::Local context(GetIsolate()->GetCurrentContext()); + int linenum = message->GetLineNumber(context).FromJust(); + v8::String::Utf8Value sourceline( + GetIsolate(), message->GetSourceLine(context).ToLocalChecked()); + fprintf(stderr, "Line %d: %s\n", linenum, *sourceline); + } #endif // NDEBUG if (lpRetValue) { -- cgit v1.2.3