Index: gin/try_catch.cc |
diff --git a/gin/try_catch.cc b/gin/try_catch.cc |
index 97e7fe15f832b33af9d5648152c2f4986a0f137b..df27b9c1e4f3dc924078ebc65a0128c76c37412c 100644 |
--- a/gin/try_catch.cc |
+++ b/gin/try_catch.cc |
@@ -8,9 +8,21 @@ |
#include "gin/converter.h" |
+namespace { |
+ |
+v8::Local<v8::String> GetSourceLine(v8::Isolate* isolate, |
+ v8::Local<v8::Message> message) { |
+ auto maybe = message->GetSourceLine(isolate->GetCurrentContext()); |
+ v8::Local<v8::String> source_line; |
+ return maybe.ToLocal(&source_line) ? source_line : v8::String::Empty(isolate); |
+} |
+ |
+} // namespace |
+ |
namespace gin { |
-TryCatch::TryCatch() { |
+TryCatch::TryCatch(v8::Isolate* isolate) |
+ : isolate_(isolate), try_catch_(isolate) { |
} |
TryCatch::~TryCatch() { |
@@ -28,7 +40,7 @@ std::string TryCatch::GetStackTrace() { |
std::stringstream ss; |
v8::Local<v8::Message> message = try_catch_.Message(); |
ss << V8ToString(message->Get()) << std::endl |
- << V8ToString(message->GetSourceLine()) << std::endl; |
+ << V8ToString(GetSourceLine(isolate_, message)) << std::endl; |
v8::Local<v8::StackTrace> trace = message->GetStackTrace(); |
if (trace.IsEmpty()) |