[xfa] Dump JS errors to console in debug mode This CL writes any JS exceptions to the console in XFA if running in Debug mode. This makes it possible to see when an error happens in JS execution. Bug: pdfium:1097 Change-Id: Ida14050328c5e6e85ab2704bb5dddfec370dddf1 Reviewed-on: https://pdfium-review.googlesource.com/33154 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp index 03bcc4d..6f2b770 100644 --- a/fxjs/cfxjse_context.cpp +++ b/fxjs/cfxjse_context.cpp
@@ -293,9 +293,16 @@ ASSERT(!trycatch.HasCaught()); if (lpRetValue) lpRetValue->m_hValue.Reset(m_pIsolate, hValue); + return true; } } + +#ifndef NDEBUG + v8::String::Utf8Value error(GetIsolate(), trycatch.Exception()); + fprintf(stderr, "JS Error: %ls\n", WideString::FromUTF8(*error).c_str()); +#endif // NDEBUG + if (lpRetValue) { lpRetValue->m_hValue.Reset(m_pIsolate, CreateReturnValue(m_pIsolate, trycatch));