[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame^] | 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. |
| 4 | |
| 5 | #include "gin/try_catch.h" |
| 6 | |
| 7 | #include "gin/converter.h" |
| 8 | |
| 9 | namespace gin { |
| 10 | |
| 11 | TryCatch::TryCatch() { |
| 12 | } |
| 13 | |
| 14 | TryCatch::~TryCatch() { |
| 15 | } |
| 16 | |
| 17 | bool TryCatch::HasCaught() { |
| 18 | return try_catch_.HasCaught(); |
| 19 | } |
| 20 | |
| 21 | std::string TryCatch::GetPrettyMessage() { |
| 22 | std::string info; |
| 23 | ConvertFromV8(try_catch_.Message()->Get(), &info); |
| 24 | |
| 25 | std::string sounce_line; |
| 26 | if (ConvertFromV8(try_catch_.Message()->GetSourceLine(), &sounce_line)) |
| 27 | info += "\n" + sounce_line; |
| 28 | |
| 29 | return info; |
| 30 | } |
| 31 | |
| 32 | } // namespace gin |