blob: 4f0656cb6537abc816819336806b77460681eed8 [file] [log] [blame]
[email protected]855ab432013-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
[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
[email protected]48c21632013-12-12 21:32:3410#include "gin/gin_export.h"
Dan Elphick05acd602021-08-30 15:22:0711#include "v8/include/v8-exception.h"
[email protected]855ab432013-11-18 17:09:3612
13namespace gin {
14
[email protected]60531d52013-11-27 02:10:1515// TryCatch is a convenient wrapper around v8::TryCatch.
[email protected]48c21632013-12-12 21:32:3416class GIN_EXPORT TryCatch {
[email protected]855ab432013-11-18 17:09:3617 public:
bashidbd2ef9bb2015-06-02 01:39:3218 explicit TryCatch(v8::Isolate* isolate);
Daniel Hosseinian68c0798d2021-04-16 08:16:0719 TryCatch(const TryCatch&) = delete;
20 TryCatch& operator=(const TryCatch&) = delete;
[email protected]855ab432013-11-18 17:09:3621 ~TryCatch();
22
23 bool HasCaught();
[email protected]2f703422013-11-25 21:26:1524 std::string GetStackTrace();
[email protected]855ab432013-11-18 17:09:3625
26 private:
bashidbd2ef9bb2015-06-02 01:39:3227 v8::Isolate* isolate_;
[email protected]855ab432013-11-18 17:09:3628 v8::TryCatch try_catch_;
[email protected]855ab432013-11-18 17:09:3629};
30
31} // namespace gin
32
[email protected]60531d52013-11-27 02:10:1533#endif // GIN_TRY_CATCH_H_