Loading...
Searching...
No Matches
v8-exception.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project 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#ifndef INCLUDE_V8_EXCEPTION_H_
6#define INCLUDE_V8_EXCEPTION_H_
7
8#include <stddef.h>
9
10#include "v8-local-handle.h" // NOLINT(build/include_directory)
11#include "v8-object.h" // NOLINT(build/include_directory)
12#include "v8config.h" // NOLINT(build/include_directory)
13
14namespace v8 {
15
16class Context;
17class Isolate;
18class Message;
19class StackTrace;
20class String;
21class Value;
22
23namespace internal {
24class Isolate;
25class ThreadLocalTop;
26} // namespace internal
27
33 public:
35 Local<Value> options = {});
37 Local<Value> options = {});
39 Local<Value> options = {});
41 Local<Value> options = {});
43 Local<Value> options = {});
45 Local<Value> options = {});
47 Local<Value> options = {});
48 static Local<Value> Error(Local<String> message, Local<Value> options = {});
49
55 static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
56
62
68 Local<Object> object);
69};
70
75 public:
81 explicit TryCatch(Isolate* isolate);
82
87
91 bool HasCaught() const;
92
101 bool CanContinue() const;
102
115 bool HasTerminated() const;
116
125
131
137 Local<Context> context, Local<Value> exception);
138
145 Local<Context> context) const;
146
152
163 void Reset();
164
173 void SetVerbose(bool value);
174
178 bool IsVerbose() const;
179
185 void SetCaptureMessage(bool value);
186
187 TryCatch(const TryCatch&) = delete;
188 void operator=(const TryCatch&) = delete;
189
190 private:
191 // Declaring operator new and delete as deleted is not spec compliant.
192 // Therefore declare them private instead to disable dynamic alloc
193 void* operator new(size_t size);
194 void* operator new[](size_t size);
195 void operator delete(void*, size_t);
196 void operator delete[](void*, size_t);
197
209 internal::Address JSStackComparableAddressPrivate() {
210 return js_stack_comparable_address_;
211 }
212
213 void ResetInternal();
214
215 internal::Isolate* i_isolate_;
216 TryCatch* next_;
217 void* exception_;
218 void* message_obj_;
219 internal::Address js_stack_comparable_address_;
220 bool is_verbose_ : 1;
221 bool can_continue_ : 1;
222 bool capture_message_ : 1;
223 bool rethrow_ : 1;
224
225 friend class internal::Isolate;
226 friend class internal::ThreadLocalTop;
227};
228
229} // namespace v8
230
231#endif // INCLUDE_V8_EXCEPTION_H_
Definition: v8-exception.h:32
static Maybe< bool > CaptureStackTrace(Local< Context > context, Local< Object > object)
static Local< Message > CreateMessage(Isolate *isolate, Local< Value > exception)
static Local< StackTrace > GetStackTrace(Local< Value > exception)
static Local< Value > RangeError(Local< String > message, Local< Value > options={})
static Local< Value > TypeError(Local< String > message, Local< Value > options={})
static Local< Value > WasmRuntimeError(Local< String > message, Local< Value > options={})
static Local< Value > ReferenceError(Local< String > message, Local< Value > options={})
static Local< Value > WasmCompileError(Local< String > message, Local< Value > options={})
static Local< Value > SyntaxError(Local< String > message, Local< Value > options={})
static Local< Value > WasmLinkError(Local< String > message, Local< Value > options={})
static Local< Value > Error(Local< String > message, Local< Value > options={})
Definition: v8-isolate.h:210
Definition: v8-local-handle.h:258
Definition: v8-local-handle.h:619
Definition: v8-maybe.h:32
Definition: v8-exception.h:74
void SetVerbose(bool value)
Local< v8::Message > Message() const
bool HasTerminated() const
MaybeLocal< Value > StackTrace(Local< Context > context) const
void SetCaptureMessage(bool value)
TryCatch(Isolate *isolate)
TryCatch(const TryCatch &)=delete
static MaybeLocal< Value > StackTrace(Local< Context > context, Local< Value > exception)
void operator=(const TryCatch &)=delete
Local< Value > ReThrow()
bool IsVerbose() const
Local< Value > Exception() const
bool HasCaught() const
bool CanContinue() const
uintptr_t Address
Definition: v8-internal.h:31
Definition: libplatform.h:15
#define V8_EXPORT
Definition: v8config.h:762
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:637