From 0789714191b4b3109f7d5c415663090018e27577 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 30 May 2018 18:09:31 +0000 Subject: [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 Reviewed-by: Ryan Harrison --- fxjs/cfxjse_context.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp index 03bcc4d6ab..6f2b770bdc 100644 --- a/fxjs/cfxjse_context.cpp +++ b/fxjs/cfxjse_context.cpp @@ -293,9 +293,16 @@ bool CFXJSE_Context::ExecuteScript(const char* szScript, 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)); -- cgit v1.2.3