Avi Drissman | 468e51b6 | 2022-09-13 20:47:01 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 60531d5 | 2013-11-27 02:10:15 | [diff] [blame] | 5 | #ifndef GIN_TRY_CATCH_H_ |
6 | #define GIN_TRY_CATCH_H_ | ||||
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | |||||
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 10 | #include "base/memory/raw_ptr.h" |
[email protected] | 48c2163 | 2013-12-12 21:32:34 | [diff] [blame] | 11 | #include "gin/gin_export.h" |
Dan Elphick | 05acd60 | 2021-08-30 15:22:07 | [diff] [blame] | 12 | #include "v8/include/v8-exception.h" |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 13 | |
14 | namespace gin { | ||||
15 | |||||
[email protected] | 60531d5 | 2013-11-27 02:10:15 | [diff] [blame] | 16 | // TryCatch is a convenient wrapper around v8::TryCatch. |
[email protected] | 48c2163 | 2013-12-12 21:32:34 | [diff] [blame] | 17 | class GIN_EXPORT TryCatch { |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 18 | public: |
bashi | dbd2ef9bb | 2015-06-02 01:39:32 | [diff] [blame] | 19 | explicit TryCatch(v8::Isolate* isolate); |
Daniel Hosseinian | 68c0798d | 2021-04-16 08:16:07 | [diff] [blame] | 20 | TryCatch(const TryCatch&) = delete; |
21 | TryCatch& operator=(const TryCatch&) = delete; | ||||
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 22 | ~TryCatch(); |
23 | |||||
24 | bool HasCaught(); | ||||
[email protected] | 2f70342 | 2013-11-25 21:26:15 | [diff] [blame] | 25 | std::string GetStackTrace(); |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 26 | |
27 | private: | ||||
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 28 | raw_ptr<v8::Isolate> isolate_; |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 29 | v8::TryCatch try_catch_; |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 30 | }; |
31 | |||||
32 | } // namespace gin | ||||
33 | |||||
[email protected] | 60531d5 | 2013-11-27 02:10:15 | [diff] [blame] | 34 | #endif // GIN_TRY_CATCH_H_ |