Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: gin/try_catch.cc

Issue 1152653004: Re-land: gin: Use V8 Maybe APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/try_catch.h ('k') | gin/wrappable.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « gin/try_catch.h ('k') | gin/wrappable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698