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

Unified Diff: gin/try_catch.cc

Issue 1106393002: gin: Use V8 Maybe APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maybe-gin-converter
Patch Set: Created 5 years, 8 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
« gin/converter.h ('K') | « 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 a44e28e9fe53c90675852e87baf29945e075d11c..83cd40332d7a7023ce0c90aebe17cc59406a0c34 100644
--- a/gin/try_catch.cc
+++ b/gin/try_catch.cc
@@ -8,9 +8,20 @@
#include "gin/converter.h"
+namespace {
+
+v8::Local<v8::String> GetSourceLine(v8::Local<v8::Message> message) {
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ 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() : try_catch_(v8::Isolate::GetCurrent()) {
jochen (gone - plz use gerrit) 2015/04/28 11:14:20 no calls to GetCurrent please
bashi 2015/05/01 03:50:35 Done.
}
TryCatch::~TryCatch() {
@@ -28,7 +39,7 @@ std::string TryCatch::GetStackTrace() {
std::stringstream ss;
v8::Handle<v8::Message> message = try_catch_.Message();
ss << V8ToString(message->Get()) << std::endl
- << V8ToString(message->GetSourceLine()) << std::endl;
+ << V8ToString(GetSourceLine(message)) << std::endl;
v8::Handle<v8::StackTrace> trace = message->GetStackTrace();
if (trace.IsEmpty())
« gin/converter.h ('K') | « gin/try_catch.h ('k') | gin/wrappable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698