From b720d0a14601f1496ef15297bc46d401f5a2a890 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 2 Mar 2015 12:18:50 -0800 Subject: Return error information from pdfium to JS. This implements the previously unimplemented JS_Error() function. Along the way: - fix some IWYU when the include order in global.cpp was perturbed. - remove some uses of JS_ErrorString, to increase transparency. - use vp.IsSetting() in place of !vp.IsGetting() for clarity. - specify an error string on several error return paths. - add an error string for writing readonly properties. - rename an error string constant to reflect the actual message. - replace calls to variadic Format() with a function doing string appends. - remove unused JS_GetClassName() R=thestig@chromium.org Review URL: https://codereview.chromium.org/963193003 --- fpdfsdk/src/jsapi/fxjs_v8.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'fpdfsdk/src/jsapi/fxjs_v8.cpp') diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index a3f7b6ddd3..edade5fb94 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -457,9 +457,14 @@ int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName) return -1; } -void JS_Error(v8::Value * pError,const wchar_t * main,const wchar_t * sub) +void JS_Error(v8::Isolate* isolate, const CFX_WideString& message) { - + // Conversion from pdfium's wchar_t wide-strings to v8's uint16_t + // wide-strings isn't handled by v8, so use UTF8 as a common + // intermediate format. + CFX_ByteString utf8_message = message.UTF8Encode(); + isolate->ThrowException(v8::String::NewFromUtf8(isolate, + utf8_message.c_str())); } unsigned JS_CalcHash(const wchar_t* main, unsigned nLen) @@ -491,11 +496,6 @@ const wchar_t* JS_GetTypeof(v8::Handle pObj) return NULL; } -const wchar_t* JS_GetClassname(v8::Handle pObj) -{ - return NULL; -} - void JS_SetPrivate(v8::Handle pObj, void* p) { JS_SetPrivate(NULL, pObj, p); -- cgit v1.2.3