From c218854bc88039e9456f8c9a643b74952d6b4480 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 16 Apr 2018 22:17:50 +0800 Subject: [PATCH] src: add THROW_ERR_* helpers PR-URL: https://github.com/nodejs/node/pull/20121 Reviewed-By: Daniel Bevenius Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- src/node_errors.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node_errors.h b/src/node_errors.h index f34beb6fbc94cd..4153553f5be0a9 100644 --- a/src/node_errors.h +++ b/src/node_errors.h @@ -32,6 +32,9 @@ namespace node { e->Set(isolate->GetCurrentContext(), OneByteString(isolate, "code"), \ js_code).FromJust(); \ return e; \ + } \ + inline void THROW_ ## code(Environment* env, const char* message) { \ + env->isolate()->ThrowException(code(env->isolate(), message)); \ } ERRORS_WITH_CODE(V) #undef V @@ -44,6 +47,9 @@ namespace node { #define V(code, message) \ inline v8::Local code(v8::Isolate* isolate) { \ return code(isolate, message); \ + } \ + inline void THROW_ ## code(Environment* env) { \ + env->isolate()->ThrowException(code(env->isolate(), message)); \ } PREDEFINED_ERROR_MESSAGES(V) #undef V