From f9d0166291956394d2e5abf7a0c48e760d9cfe2a Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 23 Mar 2016 17:02:04 -0600 Subject: [PATCH] src: reword command and add ternary Make comment clear that Undefined() is returned for legacy compatibility. This will change in the future as a semver-major change, but to be able to port this to previous releases it needs to stay as is. PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis Reviewed-By: Andreas Madsen --- src/node.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/node.cc b/src/node.cc index 9d48581d5f29e8..e869a9ee724f04 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1187,11 +1187,10 @@ Local MakeCallback(Environment* env, } if (ret.IsEmpty()) { - if (callback_scope.in_makecallback()) - return ret; - // NOTE: Undefined() is returned here for backwards compatibility. - else - return Undefined(env->isolate()); + // NOTE: For backwards compatibility with public API we return Undefined() + // if the top level call threw. + return callback_scope.in_makecallback() ? + ret : Undefined(env->isolate()).As(); } if (has_domain) {