diff options
Diffstat (limited to 'src/node_util.cc')
-rw-r--r-- | src/node_util.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc index c1dff77386..bbbea9ea22 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -84,6 +84,12 @@ static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) { args.GetReturnValue().Set(ret); } +// Side effect-free stringification that will never throw exceptions. +static void SafeToString(const FunctionCallbackInfo<Value>& args) { + auto context = args.GetIsolate()->GetCurrentContext(); + args.GetReturnValue().Set(args[0]->ToDetailString(context).ToLocalChecked()); +} + inline Local<Private> IndexToPrivateSymbol(Environment* env, uint32_t index) { #define V(name, _) &Environment::name, static Local<Private> (Environment::*const methods[])() const = { @@ -221,6 +227,7 @@ void Initialize(Local<Object> target, env->SetMethod(target, "setHiddenValue", SetHiddenValue); env->SetMethod(target, "getPromiseDetails", GetPromiseDetails); env->SetMethod(target, "getProxyDetails", GetProxyDetails); + env->SetMethod(target, "safeToString", SafeToString); env->SetMethod(target, "startSigintWatchdog", StartSigintWatchdog); env->SetMethod(target, "stopSigintWatchdog", StopSigintWatchdog); |