From 2e010afb0e80499b415a7538e92ab673f5bfa183 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Tue, 6 Nov 2018 20:30:49 +0300 Subject: [PATCH] Improved wording for "not a function" exception. --- njs/njs_vm.c | 7 ++++++- njs/test/njs_unit_test.c | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/njs/njs_vm.c b/njs/njs_vm.c index 3b09717e..1e7fb9b4 100644 --- a/njs/njs_vm.c +++ b/njs/njs_vm.c @@ -1847,9 +1847,14 @@ njs_function_frame_create(njs_vm_t *vm, njs_value_t *value, return njs_function_native_frame(vm, function, this, NULL, nargs, 0, ctor); } + + njs_type_error(vm, "%s is not a constructor", + njs_type_string(value->type)); + + return NXT_ERROR; } - njs_type_error(vm, "object is not callable"); + njs_type_error(vm, "%s is not a function", njs_type_string(value->type)); return NXT_ERROR; } diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 7ed8bff4..79fb924d 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -5184,7 +5184,7 @@ static njs_unit_test_t njs_test[] = nxt_string("OKundefined") }, { nxt_string("var a = 1; a()"), - nxt_string("TypeError: object is not callable") }, + nxt_string("TypeError: number is not a function") }, { nxt_string("var o = {a:1}; o.a()"), nxt_string("TypeError: 'a' is not a function") }, @@ -5672,10 +5672,10 @@ static njs_unit_test_t njs_test[] = nxt_string("object") }, { nxt_string("new decodeURI('%00')"), - nxt_string("TypeError: object is not callable")}, + nxt_string("TypeError: function is not a constructor")}, { nxt_string("new ''.toString"), - nxt_string("TypeError: object is not callable")}, + nxt_string("TypeError: function is not a constructor")}, { nxt_string("function F() { return Number }" "var o = new (F())(5);" -- 2.47.3