Warning, file /include/node/v8-exception.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef INCLUDE_V8_EXCEPTION_H_
0006 #define INCLUDE_V8_EXCEPTION_H_
0007
0008 #include <stddef.h>
0009
0010 #include "v8-local-handle.h" // NOLINT(build/include_directory)
0011 #include "v8-object.h" // NOLINT(build/include_directory)
0012 #include "v8config.h" // NOLINT(build/include_directory)
0013
0014 namespace v8 {
0015
0016 class Context;
0017 class Isolate;
0018 class Message;
0019 class StackTrace;
0020 class String;
0021 class Value;
0022
0023 namespace internal {
0024 class Isolate;
0025 class ThreadLocalTop;
0026 }
0027
0028
0029
0030
0031
0032 class V8_EXPORT Exception {
0033 public:
0034 static Local<Value> RangeError(Local<String> message,
0035 Local<Value> options = {});
0036 static Local<Value> ReferenceError(Local<String> message,
0037 Local<Value> options = {});
0038 static Local<Value> SyntaxError(Local<String> message,
0039 Local<Value> options = {});
0040 static Local<Value> TypeError(Local<String> message,
0041 Local<Value> options = {});
0042 static Local<Value> WasmCompileError(Local<String> message,
0043 Local<Value> options = {});
0044 static Local<Value> WasmLinkError(Local<String> message,
0045 Local<Value> options = {});
0046 static Local<Value> WasmRuntimeError(Local<String> message,
0047 Local<Value> options = {});
0048 static Local<Value> WasmSuspendError(Local<String> message,
0049 Local<Value> options = {});
0050 static Local<Value> Error(Local<String> message, Local<Value> options = {});
0051
0052
0053
0054
0055
0056
0057 static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
0058
0059
0060
0061
0062
0063 static Local<StackTrace> GetStackTrace(Local<Value> exception);
0064
0065
0066
0067
0068
0069 static Maybe<bool> CaptureStackTrace(Local<Context> context,
0070 Local<Object> object);
0071 };
0072
0073
0074
0075
0076
0077
0078 enum class ExceptionContext : uint32_t {
0079 kUnknown,
0080 kConstructor,
0081 kOperation,
0082 kAttributeGet,
0083 kAttributeSet,
0084 kIndexedQuery,
0085 kIndexedGetter,
0086 kIndexedDescriptor,
0087 kIndexedSetter,
0088 kIndexedDefiner,
0089 kIndexedDeleter,
0090 kNamedQuery,
0091 kNamedGetter,
0092 kNamedDescriptor,
0093 kNamedSetter,
0094 kNamedDefiner,
0095 kNamedDeleter,
0096 kNamedEnumerator
0097 };
0098
0099
0100
0101
0102
0103
0104 class ExceptionPropagationMessage {
0105 public:
0106 ExceptionPropagationMessage(v8::Isolate* isolate, Local<Object> exception,
0107 Local<String> interface_name,
0108 Local<String> property_name,
0109 ExceptionContext exception_context)
0110 : isolate_(isolate),
0111 exception_(exception),
0112 interface_name_(interface_name),
0113 property_name_(property_name),
0114 exception_context_(exception_context) {}
0115
0116 V8_INLINE Isolate* GetIsolate() const { return isolate_; }
0117 V8_INLINE Local<Object> GetException() const { return exception_; }
0118 V8_INLINE Local<String> GetInterfaceName() const { return interface_name_; }
0119 V8_INLINE Local<String> GetPropertyName() const { return property_name_; }
0120 V8_INLINE ExceptionContext GetExceptionContext() const {
0121 return exception_context_;
0122 }
0123
0124 private:
0125 Isolate* isolate_;
0126 Local<Object> exception_;
0127 Local<String> interface_name_;
0128 Local<String> property_name_;
0129 ExceptionContext exception_context_;
0130 };
0131
0132 using ExceptionPropagationCallback =
0133 void (*)(ExceptionPropagationMessage message);
0134
0135
0136
0137
0138 class V8_EXPORT TryCatch {
0139 public:
0140
0141
0142
0143
0144
0145 explicit TryCatch(Isolate* isolate);
0146
0147
0148
0149
0150 ~TryCatch();
0151
0152
0153
0154
0155 bool HasCaught() const;
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 bool CanContinue() const;
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179 bool HasTerminated() const;
0180
0181
0182
0183
0184
0185
0186
0187
0188 Local<Value> ReThrow();
0189
0190
0191
0192
0193
0194 Local<Value> Exception() const;
0195
0196
0197
0198
0199
0200 V8_WARN_UNUSED_RESULT static MaybeLocal<Value> StackTrace(
0201 Local<Context> context, Local<Value> exception);
0202
0203
0204
0205
0206
0207
0208 V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
0209 Local<Context> context) const;
0210
0211
0212
0213
0214
0215 Local<v8::Message> Message() const;
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227 void Reset();
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237 void SetVerbose(bool value);
0238
0239
0240
0241
0242 bool IsVerbose() const;
0243
0244
0245
0246
0247
0248
0249 void SetCaptureMessage(bool value);
0250
0251 TryCatch(const TryCatch&) = delete;
0252 void operator=(const TryCatch&) = delete;
0253
0254 private:
0255
0256
0257 void* operator new(size_t size);
0258 void* operator new[](size_t size);
0259 void operator delete(void*, size_t);
0260 void operator delete[](void*, size_t);
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273 internal::Address JSStackComparableAddressPrivate() {
0274 return js_stack_comparable_address_;
0275 }
0276
0277 void ResetInternal();
0278
0279 internal::Isolate* i_isolate_;
0280 TryCatch* next_;
0281 void* exception_;
0282 void* message_obj_;
0283 internal::Address js_stack_comparable_address_;
0284 bool is_verbose_ : 1;
0285 bool can_continue_ : 1;
0286 bool capture_message_ : 1;
0287 bool rethrow_ : 1;
0288
0289 friend class internal::Isolate;
0290 friend class internal::ThreadLocalTop;
0291 };
0292
0293 }
0294
0295 #endif