Skip to content

Commit c32d7db

Browse files
author
Gabriel Schulhof
committed
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: #506 Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 0a90df2 commit c32d7db

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

napi.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16
5151
#define NAPI_THROW_VOID(e) throw e
5252

5353
#define NAPI_THROW_IF_FAILED(env, status, ...) \
54-
if ((status) != napi_ok) throw Error::New(env);
54+
if ((status) != napi_ok) throw Napi::Error::New(env);
5555

5656
#define NAPI_THROW_IF_FAILED_VOID(env, status) \
57-
if ((status) != napi_ok) throw Error::New(env);
57+
if ((status) != napi_ok) throw Napi::Error::New(env);
5858

5959
#else // NAPI_CPP_EXCEPTIONS
6060

@@ -78,13 +78,13 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16
7878

7979
#define NAPI_THROW_IF_FAILED(env, status, ...) \
8080
if ((status) != napi_ok) { \
81-
Error::New(env).ThrowAsJavaScriptException(); \
81+
Napi::Error::New(env).ThrowAsJavaScriptException(); \
8282
return __VA_ARGS__; \
8383
}
8484

8585
#define NAPI_THROW_IF_FAILED_VOID(env, status) \
8686
if ((status) != napi_ok) { \
87-
Error::New(env).ThrowAsJavaScriptException(); \
87+
Napi::Error::New(env).ThrowAsJavaScriptException(); \
8888
return; \
8989
}
9090

@@ -93,7 +93,7 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16
9393
#define NAPI_FATAL_IF_FAILED(status, location, message) \
9494
do { \
9595
if ((status) != napi_ok) { \
96-
Error::Fatal((location), (message)); \
96+
Napi::Error::Fatal((location), (message)); \
9797
} \
9898
} while (0)
9999

0 commit comments

Comments
 (0)