Skip to content

Commit

Permalink
src: adapt to v8::Exception API change
Browse files Browse the repository at this point in the history
  • Loading branch information
targos authored and nodejs-github-bot committed Nov 27, 2023
1 parent f0171f4 commit c77f6d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
11 changes: 3 additions & 8 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,14 +775,9 @@ inline void Environment::ThrowRangeError(const char* errmsg) {
ThrowError(v8::Exception::RangeError, errmsg);
}

inline void Environment::ThrowError(V8ExceptionConstructorOld fun,
const char* errmsg) {
v8::HandleScope handle_scope(isolate());
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg)));
}

inline void Environment::ThrowError(V8ExceptionConstructorNew fun,
const char* errmsg) {
inline void Environment::ThrowError(
v8::Local<v8::Value> (*fun)(v8::Local<v8::String>, v8::Local<v8::Value>),
const char* errmsg) {
v8::HandleScope handle_scope(isolate());
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg), {}));
}
Expand Down
11 changes: 3 additions & 8 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -1016,14 +1016,9 @@ class Environment : public MemoryRetainer {
};

private:
// V8 has changed the constructor of exceptions, support both APIs before Node
// updates to V8 12.1.
using V8ExceptionConstructorOld =
v8::Local<v8::Value> (*)(v8::Local<v8::String>);
using V8ExceptionConstructorNew =
v8::Local<v8::Value> (*)(v8::Local<v8::String>, v8::Local<v8::Value>);
inline void ThrowError(V8ExceptionConstructorOld fun, const char* errmsg);
inline void ThrowError(V8ExceptionConstructorNew fun, const char* errmsg);
inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>,
v8::Local<v8::Value>),
const char* errmsg);
void TrackContext(v8::Local<v8::Context> context);
void UntrackContext(v8::Local<v8::Context> context);

Expand Down

0 comments on commit c77f6d8

Please sign in to comment.