Remove the JS key log summary, since it's of limited value without the "code" field...
[chromium-blink-merge.git] / gin / try_catch.cc
bloba44e28e9fe53c90675852e87baf29945e075d11c
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "gin/try_catch.h"
7 #include <sstream>
9 #include "gin/converter.h"
11 namespace gin {
13 TryCatch::TryCatch() {
16 TryCatch::~TryCatch() {
19 bool TryCatch::HasCaught() {
20 return try_catch_.HasCaught();
23 std::string TryCatch::GetStackTrace() {
24 if (!HasCaught()) {
25 return "";
28 std::stringstream ss;
29 v8::Handle<v8::Message> message = try_catch_.Message();
30 ss << V8ToString(message->Get()) << std::endl
31 << V8ToString(message->GetSourceLine()) << std::endl;
33 v8::Handle<v8::StackTrace> trace = message->GetStackTrace();
34 if (trace.IsEmpty())
35 return ss.str();
37 int len = trace->GetFrameCount();
38 for (int i = 0; i < len; ++i) {
39 v8::Handle<v8::StackFrame> frame = trace->GetFrame(i);
40 ss << V8ToString(frame->GetScriptName()) << ":"
41 << frame->GetLineNumber() << ":"
42 << frame->GetColumn() << ": "
43 << V8ToString(frame->GetFunctionName())
44 << std::endl;
46 return ss.str();
49 } // namespace gin