Skip to content

Commit

Permalink
src: adapt to v8::Exception API change
Browse files Browse the repository at this point in the history
Refs: v8/v8@341bce2
PR-URL: #50115
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
targos committed Jan 4, 2024
1 parent 4782818 commit 7166986
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 @@ -1029,14 +1029,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 7166986

Please sign in to comment.