From c32d7dbdcf25c69ccfaf0ab2848200cfc10c2459 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Thu, 27 Jun 2019 09:39:16 -0700 Subject: [PATCH] macros: create errors fully namespaced Errors in `NAPI_THROW()` and Co. were being thrown as `Error:New(...)` but they should be thrown as `Napi::Error::New(...)` because the former assumes that the user has opted to declare `using namespace Napi;`. PR-URL: https://github.com/nodejs/node-addon-api/pull/506 Reviewed-By: Nicola Del Gobbo Reviewed-By: Gus Caplan Reviewed-By: Michael Dawson --- napi.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/napi.h b/napi.h index 287f16da7..c1946413b 100644 --- a/napi.h +++ b/napi.h @@ -51,10 +51,10 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16 #define NAPI_THROW_VOID(e) throw e #define NAPI_THROW_IF_FAILED(env, status, ...) \ - if ((status) != napi_ok) throw Error::New(env); + if ((status) != napi_ok) throw Napi::Error::New(env); #define NAPI_THROW_IF_FAILED_VOID(env, status) \ - if ((status) != napi_ok) throw Error::New(env); + if ((status) != napi_ok) throw Napi::Error::New(env); #else // NAPI_CPP_EXCEPTIONS @@ -78,13 +78,13 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16 #define NAPI_THROW_IF_FAILED(env, status, ...) \ if ((status) != napi_ok) { \ - Error::New(env).ThrowAsJavaScriptException(); \ + Napi::Error::New(env).ThrowAsJavaScriptException(); \ return __VA_ARGS__; \ } #define NAPI_THROW_IF_FAILED_VOID(env, status) \ if ((status) != napi_ok) { \ - Error::New(env).ThrowAsJavaScriptException(); \ + Napi::Error::New(env).ThrowAsJavaScriptException(); \ return; \ } @@ -93,7 +93,7 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16 #define NAPI_FATAL_IF_FAILED(status, location, message) \ do { \ if ((status) != napi_ok) { \ - Error::Fatal((location), (message)); \ + Napi::Error::Fatal((location), (message)); \ } \ } while (0)