From 71669866268fe5c3679b8f554b4aeea59a992fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 30 Sep 2023 10:00:57 +0200 Subject: [PATCH] src: adapt to v8::Exception API change Refs: https://github.com/v8/v8/commit/341bce2202f33415e8a1ce710e4ef6834ca381c2 PR-URL: https://github.com/nodejs/node/pull/50115 Reviewed-By: Rafael Gonzaga Reviewed-By: Michael Dawson --- src/env-inl.h | 11 +++-------- src/env.h | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index d5124e73e7c4c6..56a96def344194 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -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 (*fun)(v8::Local, v8::Local), + const char* errmsg) { v8::HandleScope handle_scope(isolate()); isolate()->ThrowException(fun(OneByteString(isolate(), errmsg), {})); } diff --git a/src/env.h b/src/env.h index 9a2ac179101210..a0d6d49f321671 100644 --- a/src/env.h +++ b/src/env.h @@ -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::Local); - using V8ExceptionConstructorNew = - v8::Local (*)(v8::Local, v8::Local); - inline void ThrowError(V8ExceptionConstructorOld fun, const char* errmsg); - inline void ThrowError(V8ExceptionConstructorNew fun, const char* errmsg); + inline void ThrowError(v8::Local (*fun)(v8::Local, + v8::Local), + const char* errmsg); void TrackContext(v8::Local context); void UntrackContext(v8::Local context);