blob: a36fa29276c4f21c87b05d0ae31d2a1fc6dfe48a [file] [log] [blame]
Avi Drissman468e51b62022-09-13 20:47:011// Copyright 2013 The Chromium Authors
[email protected]855ab432013-11-18 17:09:362// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]60531d52013-11-27 02:10:155#ifndef GIN_TRY_CATCH_H_
6#define GIN_TRY_CATCH_H_
[email protected]855ab432013-11-18 17:09:367
8#include <string>
9
Keishi Hattori0e45c022021-11-27 09:25:5210#include "base/memory/raw_ptr.h"
[email protected]48c21632013-12-12 21:32:3411#include "gin/gin_export.h"
Dan Elphick05acd602021-08-30 15:22:0712#include "v8/include/v8-exception.h"
[email protected]855ab432013-11-18 17:09:3613
14namespace gin {
15
[email protected]60531d52013-11-27 02:10:1516// TryCatch is a convenient wrapper around v8::TryCatch.
[email protected]48c21632013-12-12 21:32:3417class GIN_EXPORT TryCatch {
[email protected]855ab432013-11-18 17:09:3618 public:
bashidbd2ef9bb2015-06-02 01:39:3219 explicit TryCatch(v8::Isolate* isolate);
Daniel Hosseinian68c0798d2021-04-16 08:16:0720 TryCatch(const TryCatch&) = delete;
21 TryCatch& operator=(const TryCatch&) = delete;
[email protected]855ab432013-11-18 17:09:3622 ~TryCatch();
23
24 bool HasCaught();
[email protected]2f703422013-11-25 21:26:1525 std::string GetStackTrace();
[email protected]855ab432013-11-18 17:09:3626
27 private:
Keishi Hattori0e45c022021-11-27 09:25:5228 raw_ptr<v8::Isolate> isolate_;
[email protected]855ab432013-11-18 17:09:3629 v8::TryCatch try_catch_;
[email protected]855ab432013-11-18 17:09:3630};
31
32} // namespace gin
33
[email protected]60531d52013-11-27 02:10:1534#endif // GIN_TRY_CATCH_H_