diff --git a/v8pp/throw_ex.hpp b/v8pp/throw_ex.hpp index 20675f05..08c4fc1c 100644 --- a/v8pp/throw_ex.hpp +++ b/v8pp/throw_ex.hpp @@ -15,6 +15,21 @@ constexpr bool exception_ctor_with_options = V8_MAJOR_VERSION > 11 || (V8_MAJOR_ v8::Local throw_ex(v8::Isolate* isolate, std::string_view message, exception_ctor ctor = v8::Exception::Error, v8::Local exception_options = {}); +v8::Local throw_error(v8::Isolate* isolate, std::string_view message, + v8::Local exception_options = {}); + +v8::Local throw_range_error(v8::Isolate* isolate, std::string_view message, + v8::Local exception_options = {}); + +v8::Local throw_reference_error(v8::Isolate* isolate, std::string_view message, + v8::Local exception_options = {}); + +v8::Local throw_syntax_error(v8::Isolate* isolate, std::string_view message, + v8::Local exception_options = {}); + +v8::Local throw_type_error(v8::Isolate* isolate, std::string_view message, + v8::Local exception_options = {}); + } // namespace v8pp #if V8PP_HEADER_ONLY diff --git a/v8pp/throw_ex.ipp b/v8pp/throw_ex.ipp index f3db52da..3eb7386d 100644 --- a/v8pp/throw_ex.ipp +++ b/v8pp/throw_ex.ipp @@ -18,4 +18,29 @@ V8PP_IMPL v8::Local throw_ex(v8::Isolate* isolate, std::string_view m return isolate->ThrowException(ex); } +V8PP_IMPL v8::Local throw_error(v8::Isolate* isolate, std::string_view message, v8::Local exception_options) +{ + return throw_ex(isolate, message, v8::Exception::Error, exception_options); +} + +V8PP_IMPL v8::Local throw_range_error(v8::Isolate* isolate, std::string_view message, v8::Local exception_options) +{ + return throw_ex(isolate, message, v8::Exception::RangeError, exception_options); +} + +V8PP_IMPL v8::Local throw_reference_error(v8::Isolate* isolate, std::string_view message, v8::Local exception_options) +{ + return throw_ex(isolate, message, v8::Exception::ReferenceError, exception_options); +} + +V8PP_IMPL v8::Local throw_syntax_error(v8::Isolate* isolate, std::string_view message, v8::Local exception_options) +{ + return throw_ex(isolate, message, v8::Exception::SyntaxError, exception_options); +} + +V8PP_IMPL v8::Local throw_type_error(v8::Isolate* isolate, std::string_view message, v8::Local exception_options) +{ + return throw_ex(isolate, message, v8::Exception::TypeError, exception_options); +} + } // namespace v8pp