blob: edacbec82cdae203a4f3b585ce3ea1a16edc3e80 [file] [log] [blame]
abarth@chromium.org855ab432013-11-18 17:09:361// 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
abarth@chromium.org60531d52013-11-27 02:10:155#ifndef GIN_TRY_CATCH_H_
6#define GIN_TRY_CATCH_H_
abarth@chromium.org855ab432013-11-18 17:09:367
8#include <string>
9
Keishi Hattori0e45c022021-11-27 09:25:5210#include "base/memory/raw_ptr.h"
jochen@chromium.org48c21632013-12-12 21:32:3411#include "gin/gin_export.h"
Dan Elphick05acd602021-08-30 15:22:0712#include "v8/include/v8-exception.h"
abarth@chromium.org855ab432013-11-18 17:09:3613
14namespace gin {
15
abarth@chromium.org60531d52013-11-27 02:10:1516// TryCatch is a convenient wrapper around v8::TryCatch.
jochen@chromium.org48c21632013-12-12 21:32:3417class GIN_EXPORT TryCatch {
abarth@chromium.org855ab432013-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;
abarth@chromium.org855ab432013-11-18 17:09:3622 ~TryCatch();
23
24 bool HasCaught();
abarth@chromium.org2f703422013-11-25 21:26:1525 std::string GetStackTrace();
abarth@chromium.org855ab432013-11-18 17:09:3626
27 private:
Keishi Hattori0e45c022021-11-27 09:25:5228 raw_ptr<v8::Isolate> isolate_;
abarth@chromium.org855ab432013-11-18 17:09:3629 v8::TryCatch try_catch_;
abarth@chromium.org855ab432013-11-18 17:09:3630};
31
32} // namespace gin
33
abarth@chromium.org60531d52013-11-27 02:10:1534#endif // GIN_TRY_CATCH_H_