Index: src/Utils.cpp |
=================================================================== |
--- a/src/Utils.cpp |
+++ b/src/Utils.cpp |
@@ -45,32 +45,39 @@ |
{ |
v8::String::Utf8Value stringValue(isolate, value); |
if (stringValue.length()) |
return IFileSystem::IOBuffer(*stringValue, *stringValue + stringValue.length()); |
else |
return IFileSystem::IOBuffer(); |
} |
-v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string& str) |
+v8::MaybeLocal<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string& str) |
{ |
return v8::String::NewFromUtf8(isolate, str.c_str(), |
- v8::String::NewStringType::kNormalString, str.length()); |
+ v8::NewStringType::kNormal, str.length()); |
} |
-v8::Local<v8::String> Utils::StringBufferToV8String(v8::Isolate* isolate, const StringBuffer& str) |
+v8::MaybeLocal<v8::String> Utils::StringBufferToV8String(v8::Isolate* isolate, const StringBuffer& str) |
{ |
return v8::String::NewFromUtf8(isolate, |
reinterpret_cast<const char*>(str.data()), |
- v8::String::NewStringType::kNormalString, str.size()); |
+ v8::NewStringType::kNormal, str.size()); |
} |
void Utils::ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str) |
{ |
- isolate->ThrowException(Utils::ToV8String(isolate, str)); |
+ auto maybe = Utils::ToV8String(isolate, str); |
+ if (maybe.IsEmpty()) |
+ { |
+ isolate->ThrowException( |
+ Utils::ToV8String(isolate, "Unknown Exception").ToLocalChecked()); |
hub
2018/06/22 00:34:31
Failure throwing an exception. Not good. So at lea
sergei
2018/06/22 06:57:46
I'm not sure how it works. Can we create a couple
hub
2018/06/22 15:50:56
Right now, the gist is that if we can't obtain the
sergei
2018/07/05 08:39:00
But it can be changed later and it can start to re
|
+ } |
+ else |
+ isolate->ThrowException(maybe.ToLocalChecked()); |
} |
#ifdef _WIN32 |
std::wstring Utils::ToUtf16String(const std::string& str) |
{ |
size_t length = str.size(); |
if (length == 0) |
return std::wstring(); |