From: Dmitry Volyntsev Date: Wed, 3 Jun 2026 02:07:40 +0000 (-0700) Subject: Modules: fixed common helper exception classes X-Git-Tag: 1.0.0~23 X-Git-Url: http://git.kaiwu.me/sitemap.xml?a=commitdiff_plain;h=0bdc82115c1020281e98fd6b00395ea8b7c837fe;p=njs.git Modules: fixed common helper exception classes Align common helper failures with the exception policy used by both engines: invalid numeric conversion is TypeError, and missing external receiver/context for common log helpers is TypeError rather than an internal host failure. The numeric conversion message changes from "is not a number" to "invalid number" to match the QuickJS helper text. --- diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c index 59f48436..cd44127b 100644 --- a/nginx/ngx_js.c +++ b/nginx/ngx_js.c @@ -1896,7 +1896,7 @@ ngx_qjs_ext_log(JSContext *cx, JSValueConst this_val, int argc, p = JS_GetContextOpaque(cx); if (p == NULL) { - return JS_ThrowInternalError(cx, "external is not set"); + return JS_ThrowTypeError(cx, "external is not set"); } level = magic & NGX_JS_LOG_MASK; @@ -2466,7 +2466,7 @@ ngx_js_integer(njs_vm_t *vm, njs_value_t *value, ngx_int_t *n) double num; if (!njs_value_is_valid_number(value)) { - njs_vm_error(vm, "is not a number"); + njs_vm_type_error(vm, "invalid number"); return NGX_ERROR; } @@ -2828,7 +2828,7 @@ ngx_js_ext_log(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, p = njs_vm_external(vm, NJS_PROTO_ID_ANY, njs_argument(args, 0)); if (p == NULL) { - njs_vm_error(vm, "\"this\" is not an external"); + njs_vm_type_error(vm, "external is not set"); return NJS_ERROR; }