v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
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
63 static Local<StackTrace> GetStackTrace(Local<Value> exception);
64
69 static Maybe<bool> CaptureStackTrace(Local<Context> context,
70 Local<Object> object);
71};
72
98
131
133 void (*)(ExceptionPropagationMessage message);
134
139 public:
145 explicit TryCatch(Isolate* isolate);
146
150 ~TryCatch();
151
155 bool HasCaught() const;
156
165 bool CanContinue() const;
166
179 bool HasTerminated() const;
180
188 Local<Value> ReThrow();
189
194 Local<Value> Exception() const;
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
274 return js_stack_comparable_address_;
275 }
276
277 void ResetInternal();
278
284 bool is_verbose_ : 1;
287 bool rethrow_ : 1;
288
289 friend class internal::Isolate;
291};
292
293} // namespace v8
294
295#endif // INCLUDE_V8_EXCEPTION_H_
V8_INLINE Isolate * GetIsolate() const
ExceptionContext exception_context_
V8_INLINE ExceptionContext GetExceptionContext() const
V8_INLINE Local< String > GetInterfaceName() const
V8_INLINE Local< String > GetPropertyName() const
ExceptionPropagationMessage(v8::Isolate *isolate, Local< Object > exception, Local< String > interface_name, Local< String > property_name, ExceptionContext exception_context)
V8_INLINE Local< Object > GetException() const
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={})
void * exception_
void * message_obj_
TryCatch(const TryCatch &)=delete
internal::Address JSStackComparableAddressPrivate()
internal::Address js_stack_comparable_address_
void operator=(const TryCatch &)=delete
bool capture_message_
internal::Isolate * i_isolate_
TryCatch * next_
v8_inspector::String16 String
Definition string-util.h:26
void(*)(ExceptionPropagationMessage message) ExceptionPropagationCallback
ExceptionContext
#define V8_EXPORT
Definition v8config.h:800
#define V8_INLINE
Definition v8config.h:500
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671