Welcome! Log In Create A New Profile

Advanced

[njs] Improved wording for "not a function" exception.

Dmitry Volyntsev
November 06, 2018 01:00PM
details: http://hg.nginx.org/njs/rev/1df0fea011d1
branches:
changeset: 637:1df0fea011d1
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Nov 06 20:30:49 2018 +0300
description:
Improved wording for "not a function" exception.

diffstat:

njs/njs_vm.c | 7 ++++++-
njs/test/njs_unit_test.c | 6 +++---
2 files changed, 9 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r a3a0d5850b1a -r 1df0fea011d1 njs/njs_vm.c
--- a/njs/njs_vm.c Wed Oct 31 16:06:06 2018 +0300
+++ b/njs/njs_vm.c Tue Nov 06 20:30:49 2018 +0300
@@ -1847,9 +1847,14 @@ njs_function_frame_create(njs_vm_t *vm,
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 -r a3a0d5850b1a -r 1df0fea011d1 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Wed Oct 31 16:06:06 2018 +0300
+++ b/njs/test/njs_unit_test.c Tue Nov 06 20:30:49 2018 +0300
@@ -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);"
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Improved wording for "not a function" exception.

Dmitry Volyntsev 255 November 06, 2018 01:00PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 264
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready