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 = {});
49 Local<Value> options = {});
50 static Local<Value> Error(Local<String> message, Local<Value> options = {});
51
57 static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
58
64
70 Local<Object> object);
71};
72
78enum class ExceptionContext : uint32_t {
97};
98
105 public:
107 Local<String> interface_name,
108 Local<String> property_name,
109 ExceptionContext exception_context)
110 : isolate_(isolate),
111 exception_(exception),
112 interface_name_(interface_name),
113 property_name_(property_name),
114 exception_context_(exception_context) {}
115
116 V8_INLINE Isolate* GetIsolate() const { return isolate_; }
117 V8_INLINE Local<Object> GetException() const { return exception_; }
118 V8_INLINE Local<String> GetInterfaceName() const { return interface_name_; }
119 V8_INLINE Local<String> GetPropertyName() const { return property_name_; }
121 return exception_context_;
122 }
123
124 private:
125 Isolate* isolate_;
126 Local<Object> exception_;
127 Local<String> interface_name_;
128 Local<String> property_name_;
129 ExceptionContext exception_context_;
130};
131
133 void (*)(ExceptionPropagationMessage message);
134
139 public:
145 explicit TryCatch(Isolate* isolate);
146
151
155 bool HasCaught() const;
156
165 bool CanContinue() const;
166
179 bool HasTerminated() const;
180
189
195
201 Local<Context> context, Local<Value> exception);
202
209 Local<Context> context) const;
210
216
227 void Reset();
228
237 void SetVerbose(bool value);
238
242 bool IsVerbose() const;
243
249 void SetCaptureMessage(bool value);
250
251 TryCatch(const TryCatch&) = delete;
252 void operator=(const TryCatch&) = delete;
253
254 private:
255 // Declaring operator new and delete as deleted is not spec compliant.
256 // Therefore declare them private instead to disable dynamic alloc
257 void* operator new(size_t size);
258 void* operator new[](size_t size);
259 void operator delete(void*, size_t);
260 void operator delete[](void*, size_t);
261
273 internal::Address JSStackComparableAddressPrivate() {
274 return js_stack_comparable_address_;
275 }
276
277 void ResetInternal();
278
279 internal::Isolate* i_isolate_;
280 TryCatch* next_;
281 void* exception_;
282 void* message_obj_;
283 internal::Address js_stack_comparable_address_;
284 bool is_verbose_ : 1;
285 bool can_continue_ : 1;
286 bool capture_message_ : 1;
287 bool rethrow_ : 1;
288
289 friend class internal::Isolate;
290 friend class internal::ThreadLocalTop;
291};
292
293} // namespace v8
294
295#endif // INCLUDE_V8_EXCEPTION_H_
Definition: v8-exception.h:104
Local< String > GetPropertyName() const
Definition: v8-exception.h:119
Isolate * GetIsolate() const
Definition: v8-exception.h:116
Local< Object > GetException() const
Definition: v8-exception.h:117
Local< String > GetInterfaceName() const
Definition: v8-exception.h:118
ExceptionContext GetExceptionContext() const
Definition: v8-exception.h:120
ExceptionPropagationMessage(v8::Isolate *isolate, Local< Object > exception, Local< String > interface_name, Local< String > property_name, ExceptionContext exception_context)
Definition: v8-exception.h:106
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 > WasmSuspendError(Local< String > message, Local< Value > options={})
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:261
Definition: v8-local-handle.h:266
Definition: v8-local-handle.h:632
Definition: v8-maybe.h:32
Definition: v8-exception.h:138
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:52
Definition: libplatform.h:15
void(*)(ExceptionPropagationMessage message) ExceptionPropagationCallback
Definition: v8-exception.h:133
ExceptionContext
Definition: v8-exception.h:78
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:660